not-found.js not working in Dynamic Routes
Answered
Kirtland's Warbler posted this in #help-forum
Kirtland's WarblerOP
I have a file structure like this
When i go to the
app/
- favicon.ico
- [lang]/
- layout.js
- page.js
- not-found.jsWhen i go to the
/en/randomletters it creates the default NextJS 404 page, not my not-found.js. There is a solution for this?Answered by Kirtland's Warbler
I made a workaround for temporary solution. I create 404 as [lang]/404/page.js and made a route handler for catching unknown routes and redirect them to 404 page. At least this solution works fine
5 Replies
@Kirtland's Warbler I have a file structure like this
app/
- favicon.ico
- [lang]/
- layout.js
- page.js
- not-found.js
When i go to the `/en/randomletters` it creates the default NextJS 404 page, not my not-found.js. There is a solution for this?
it has to be the root not-found, so
app/not-found.jsTomistoma
he is using translations so the root not-found will not work
you have to create a catch all que create a not found in that route: https://next-intl-docs.vercel.app/docs/environments/error-files#catching-non-localized-requests something like this
@Tomistoma you have to create a catch all que create a not found in that route: https://next-intl-docs.vercel.app/docs/environments/error-files#catching-non-localized-requests something like this
Kirtland's WarblerOP
When i create app/[lang]/[...rest]/page.js it throws
Unsupported Server Component type: Null error. It can be solved?Kirtland's WarblerOP
I made a workaround for temporary solution. I create 404 as [lang]/404/page.js and made a route handler for catching unknown routes and redirect them to 404 page. At least this solution works fine
Answer