-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CloudFront cache error in Next.js with SSR when navigating via SPA (client-side) #3514
Comments
Hi all, I'm experiencing the same issue and have been investigating solutions for the past week. Symptoms are nearly identical. Ultimately, "After navigating via SPA, requests to the /__next/data/**/*.json endpoints should return the correct and up-to-date data from the server, even when CloudFront is involved." says it all. Using Next.js 13.2.4 and a standard`amplify.yml file: version: 1
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: .next
files:
- "**/*"
cache:
paths:
- node_modules/**/* The root cause seems to be pretty straight-forward, as mentioned by @hloriii in this comment on #3509, which is also an SSR issue. Sort of two issues together:
Some of my requests contain a request header of Here is a typical end-user experience: The 3rd, 4th, and 5th all do not behave as expected, returning an empty object from the
Very confusing. Attempted fixes
I can't share more details on my project, but I can share that the issue is definitely specific to what the author mentioned, a CloudFront cache error in Next.js applications that attempt to navigate client-side to a page that uses @hloriii is there a better solution for this issue? It's kind of a deal breaker for many Next.js users. Is there a way to opt out of CF until this is fixed? |
Hi @dallegrezzaRFK and @marlonconstante 👋🏽 thanks for raising this issue and providing these details on the behavior you're experiencing. We are currently looking into this to find a solution since the suggested workarounds are not helpful in this case. @dallegrezzaRFK we do not have a way to opt out of CloudFront but we are working on finding a solution for this. |
Hi @marlonconstante and @dallegrezzaRFK 👋🏽 apologies for the delay here. I've tried reproducing your behavior with a test application by following these steps:
I did not observe any empty json response in my attempts to reproduce this behavior. However, we can clearly see this occurring for your application so we are prioritizing this issue internally to gain a better understanding. We will provide an update shortly. |
Hi @dallegrezzaRFK we need some additional details from you to dive deeper on this issue. Could you provide your Amplify app ID? We also need two request IDs, one for a request that behaves as expected and one that does not. The request ID is stored under the |
Hi everyone 👋 , we are tracking this as a bug here: #3704. I'll recommend subscribing to it for any updates. Closing as duplicate. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
This issue has been automatically locked. |
Before opening, please confirm:
App Id
d1k1f08ve7vlp8
AWS Region
us-east-1
Amplify Hosting feature
SSR
Describe the bug
I have identified an issue related to the CloudFront cache managed by Amplify, which occurs when requesting data for a page after navigating via Single-Page Application (SPA) using the Next.js Link component.
The problem arises when CloudFront finds the data in its cache and returns an empty, invalid JSON response.
This response does not correspond to the actual data returned by the
getServerSideProps
method on the Next.js server.Expected behavior
After navigating via SPA, requests to the
/__next/data/**/*.json
endpoints should return the correct and up-to-date data from the server, even when CloudFront is involved.Reproduction steps
/__next/data/**/*.json
endpoints which retrieve data for the page from the server.Build Settings
Log output
Additional information
Using Next.js version 13.2.4 published on Amplify Hosting with the web compute platform.
The text was updated successfully, but these errors were encountered: