Open pranavks opened 6 months ago
i think not-found
pages are only shown when the notFound()
function is thrown. see next.js docs.
to display the nested [locale]/not-found
page, you can add a catch-all route segment at [locale]/[...404]/page.tsx
which calls notFound()
. this is what e.g. next-intl
recommends - see their docs for an example.
i think
not-found
pages are only shown when thenotFound()
function is thrown. see next.js docs.to display the nested
[locale]/not-found
page, you can add a catch-all route segment at[locale]/[...404]/page.tsx
which callsnotFound()
. this is what e.g.next-intl
recommends - see their docs for an example.
The linked doc also say it catches all the unmatched urls with this not-found.jsx;
And it does that well in our project without the [lang] folder. Only when we add the [lang] folder does this issue happen.
Will try out this catch-all route segment approach but this issue needs to be resolved on the root cause itself.
@pranavks, used like this example
.
└── src/
├── app
└── [...not_found]/
├── page.tsx
└── layout.tsx
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/nextjs-404-page-bug-internationalization-zpmm4z
To Reproduce
Current vs. Expected behavior
By default root level not-found.jsx catches all the 404 errors from non-existent inner folders. (As mentioned in docs). But after setting up internationalization by moving all files from /app to /app/[lang] folder, the not-found.jsx is not catching 404 errors from "non-existent" inner paths. It should catch them.
Provide environment information
Which area(s) are affected? (Select all that apply)
Internationalization (i18n)
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local), Other (Deployed)
Additional context
No response