-
Notifications
You must be signed in to change notification settings - Fork 26k
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
App crashes when using notFound()
with dynamic routes
#52255
Comments
The cause of this bug seems not to be dynamic routes, but instead layout under route groups. The error is not triggered if Also, I can confirm this on Next.js versions from 13.3.1-canary.5 to 13.4.10. I highly suspect this is an unintended side-effect of #48286. |
Having layout.tsx inside |
Same thing applies when I try to implement internationalization. Using https://github.com/vercel/next.js/tree/canary/examples/app-dir-i18n-routing and adding simple Next version: 13.4.10 Hope it gets fixed soon |
I was facing the same error using a [locale] directory for internationalization. Fixed it by creating a custom |
I tried this as well but it did not work. Might be because of the route groups. |
+1 not-found not working for me in route groups |
make sure you have layout.tsx in root of the app directory |
For group routes, unlike normal routes, the root layout is located in the "group"'s segment instead of root layer. To make it also able to leverage the default not found error component as root not found component, we need to determine if we're in the root group segment in the loader tree, and add the not-found boundary for it. If you compre the loader tree visually they will look like this: Normal route tree structure ``` ['', { children: [segment, {...}, {...}]}, { layout: ..., 'not-found': ... } ] ``` Group routes ``` ['' { children: ['(group)', {...}, { layout, 'not-found': ... }]} {} ] ``` Comparing to normal case, we go 1 layer down in the tree for group routes, then insert the not-found boundary there Fixes #52255 Closes NEXT-1532
This should be fixed in v13.4.19 now |
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
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:30 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8103 Binaries: Node: 18.12.0 npm: 8.19.2 Yarn: 1.22.18 pnpm: 8.6.5 Relevant Packages: next: 13.4.9-canary.2 eslint-config-next: 13.0.6 react: 18.2.0 react-dom: 18.2.0 typescript: 5.0.4 Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), Routing (next/router, next/navigation, next/link)
Link to the code that reproduces this issue or a replay of the bug
https://stackblitz.com/edit/stackblitz-starters-fxybus?file=app%2F(website)%2Fpage.js
To Reproduce
Describe the Bug
When using
notFound();
with dynamic routes, next.js throws application error.Visit
/aboutxyz
in the above stackblitz repo to simulate the error.Expected Behavior
It should not throw error. Instead it should show default next.js 404 error page.
Which browser are you using? (if relevant)
Chrome latest
How are you deploying your application? (if relevant)
vercel
NEXT-1532
The text was updated successfully, but these errors were encountered: