-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
ISR caches 404 result, but not status code #43831
Comments
I saw it in my app and I looked at how Next.js 13 playground handles things. BTW: The console says there: |
Will this ever be fixed, this is a pretty bad bug in my opinion. Having a 404 page not return 404. |
The error is still present in last version (13.4.19) |
I currently have the same error, I am using the latest version of next.js and I have integrated i18next when I trace my links the not-found page returns status code 200 and not a 404. |
This comment has been minimized.
This comment has been minimized.
This ensures we properly set/restore the status code with ISR paths in app router so that when we set the 404 status code with `notFound` it is persisted properly. Fixes: #43831 Closes: #48342 x-ref: #49387 (comment)
Hi, this has been updated in |
If you use Suspense, then the status is 200. Therefore, you need to remove the wrapper from the Suspense in layout |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), Middleware / Edge (API routes, runtime), Routing (next/router, next/navigation, next/link)
Link to the code that reproduces this issue
https://github.com/perevernihata/nextjs-isr-404-caching
To Reproduce
Not Found
page with a 200 status code. Also, subsequent requests havex-nextjs-cache: HIT
header.Describe the Bug
With ISR enabled, nextjs caches the 404-page content, but it does not cache the status code, therefore 404 is only returned the first time, and the rest of the time it is 200.
I would think, that 400 to 500 status codes should not be cached on ISR at all.
What makes it worse is that I can not conditionally disable caching or ISR for specific results in runtime.
Expected Behavior
I would expect 1 ouf these 2 options:
Alternatively, it would be also great to have API to decide if we want this specific response to be cached or not, e.g.:
Which browser are you using? (if relevant)
Chrome, but irrelevant
How are you deploying your application? (if relevant)
AWS, but irrelevant
The text was updated successfully, but these errors were encountered: