Closed hrasoa closed 1 year ago
This is not a bug. Use the root app/not-found.tsx
for global 404 handling; other not-found.tsx
files are only triggered by an explicit notFound
.
To have different not-found
for different locales, use app/[lang]/[...notFound]/page.tsx
.
Closing, as per the docs, this is expected behavior as also pointed out above:
Good to know: In addition to catching expected notFound() errors, the root app/not-found.js file also handles any unmatched URLs for your whole application. This means users that visit a URL that is not handled by your app will be shown the UI exported by the app/not-found.js file.
https://nextjs.org/docs/app/api-reference/file-conventions/not-found
@balazsorban44, app/not-found.js file works well in development but in the build process i get the following error
build process error:
my folder structure:
env: "next": "13.5.1-canary.1"
@joulev I got confused some discussions say [...not_found] other say [...not-found] you say [...notFound] what the heck is this finally? and I have to point that [...notFound] (or what ever it is called) does not work with optional catch all routes like [[...slug]] and it errors out you can not use both together.
@joulev I got confused some discussions say [...not_found] other say [...not-found] you say [...notFound] what the heck is this finally?
It's just an ordinary catch-all route that catches all routes not matched by other routes. You can name it [...notFound]
, [...not-found]
, or even [...tomandjerry]
, it will still work.
and I have to point that [...notFound] (or what ever it is called) does not work with optional catch all routes like [[...slug]] and it errors out you can not use both together.
Of course, because two catch-alls cannot go together. If you already have a catch-all, use notFound
with the local not-found.tsx
file.
@balazsorban44 , I relocate not-found.tsx to (pages) group routes now the error is gone.
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.
Link to the code that reproduces this issue
https://codesandbox.io/p/sandbox/determined-faraday-gflwsg
To Reproduce
Browse https://gflwsg-3000.csb.app/en-us/aaaa
Current vs. Expected behavior
/app/[locale]/not-found.tsx
,Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
App Router, Routing (next/router, next/navigation, next/link)
Additional context
No response