This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
App Router: returning notFound() from generateMetadata does not change the response status code to 404 if there's a loading.tsx component #75543
Labels
Error Handling
Related to handling errors (e.g., error.tsx, global-error.tsx).
Loading UI and Streaming
Related to loading UI (loading.tsx) and streaming.
Metadata
Related to Next.js' Metadata API.
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
The text was updated successfully, but these errors were encountered: