404 Page not firing
Unanswered
Cinnamon posted this in #help-forum
CinnamonOP
I have the folder structure as seen in the image. I expect the 404 page to turn up on a path like
/anyurlthatdoesntexistbut instead I just get the default nextjs 404.32 Replies
Add a not-found.tsx outside the groups.
Meaning in the same level as the root layout
Meaning in the same level as the root layout
CinnamonOP
I do not have a single root layout. I have 2, one in admin and one in www, so in theory it should be on the same level as the www root layout.
The theory doesn't make sense because technically it wouldn't know which root you are in
Does doing /blog/gsgdgd
Work?
@Clown Does doing /blog/gsgdgd
CinnamonOP
In that case I get a 404 page, but the one I have defined inside of the blog/not-found.tsx
I setup my structure like this one basicly:
Well, with route groups, it meant to group routes together
There is no such thing as a default route
So (www) isnt the default route.
Pull the not-found.tsx outside the route groups
CinnamonOP
I tried that already, but that throws an error when I access a not found url
But if I add a layout outside of the route groups I kinda lose the purpose of the 2 root layouts which serve completly different application aspects
Hmm...
Thing is im not sure if that not-found should work or not. (Www) would still open if that is the only route group with a root page.tsx but still it might not apply not-found. Im not sure if thats intended or a bug
However, is there a problem with using 2 layouts and one root layout?
Just for testing purposes test out if the 1 root layout + notfound and 2 layouts on each route group works
CinnamonOP
Just added a root layout to the base of the app folder and then it still wont fire if the not-found.tsx lies inside of the (www) folder.
If it lies outside on the root of the app dir I get a exception
Unhandled Runtime Error
Error: notFound() is not allowed to use in root layoutReally not sure what to do here, I understand why it wont work but I dont really have an idea on how it could be fixed.
@Clown Do you know where else I can search for help? I guess a github repo ?
root layout in app dir + not-found.tsx on the same level gives you an exception?
Are you on the latest version?
13.5.4
should be up to date
I'm not on pc so i cant check really. You'll have to wait till someone else can help sadly
Masai Lion
Hi! I'm having the exact same issue 🤔
CinnamonOP
@Masai Lion I created a discussion on github earlier https://github.com/vercel/next.js/discussions/56494
Maybe someone there has an idea or suggestions