App Router: returning notFound() from generateMetadata does not change the response status code to 404 if there's a loading.tsx component #75563
Replies: 2 comments 3 replies
-
@felipedeboni Thank you for submitting an issue! The |
Beta Was this translation helpful? Give feedback.
-
The same goes for using If there is a redirect, the metadata for the page will not work properly. E.g. Discord does not show any embed for pages using redirect. Redirects breaking metadata should at least be documented imo. It would be better if Next.js just used the HTTP status codes (307, 308, 404, etc) in this case instead of trying (and failing) to stream. Since |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Link to the code that reproduces this issue
https://github.com/felipedeboni/next-404
To Reproduce
Go to: https://next-404-ten.vercel.app/with-loading
Go to: https://next-404-ten.vercel.app/with-parent-loading
Go to: https://next-404-ten.vercel.app/with-parent-loading/children
Current vs. Expected behavior
When returning notFound from generateMetadata I would expect the response to have a 404 Not Found status in order to allow pages to be removed from Google Index and others...
The alternative is awful, in middleware:
However this is going to make things slower for bots, making the web vitals score lower given there's no fetch cache on middleware and fetch calls made on middleware aren't shared (cached) with the page itself.
For regular access I it's fine to have 200 OK and just show not found component (or default), however for bots we need the proper status.
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 24.2.0: Fri Dec 6 18:56:34 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6020 Available memory (MB): 65536 Available CPU cores: 12 Binaries: Node: 20.9.0 npm: 10.1.0 Yarn: 1.22.21 pnpm: 9.4.0 Relevant Packages: next: 15.1.6 // Latest available version is detected (15.1.6). eslint-config-next: 15.1.6 react: 19.0.0 react-dom: 19.0.0 typescript: 5.7.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Loading UI and Streaming, Metadata
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local), Vercel (Deployed)
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions