Dynamic routing in nested app directory paths does not redirect to not-found.js as expected.
The issue involves nested dynamic routes in the app directory not correctly redirecting to the not-found.js page, instead throwing an error. The problem is reproducible and affects multiple users, but the exact cause and solution are not immediately clear, requiring deeper understanding of Next.js routing and app directory behavior.
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP Wed Aug 25 23:20:18 UTC 2021
Binaries:
Node: 18.14.2
npm: 9.6.4
Yarn: 1.22.19
pnpm: N/A
Relevant packages:
next: 13.3.0
eslint-config-next: 13.3.0
react: 18.2.0
react-dom: 18.2.0
App directory (appDir: true)
n/a
Using the app directory, create several folders for path segments with the last ending in a dynamic route. Here is my example:
app/(site)/memberships/benefits/[slug]/page.js
I have several other similar to this
When a dynamic path is nested within another folder path, the notFound() function does not redirect to the /not-found.js page. It instead throws an error. All other paths work fine. This is true whether the nested dynamic route is [slug] or [...slug]
I expect that the notFound() function should redirect to the not-found.js page like the other dynamic routes in this same project do.
No response
No response
Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!