I have a question about routing and 404-pages.
My website uses next.js and everything is rendered perfectly, using [slug]. For example i have “somepage.com/contact” it works fine. But every page is rendered, so if I use some url that should not exist, for example “somepage.com/qwertyuiop” it doesn’t show me a 404-page but instead shows a page with fallback- or demo content.
I get that this is due to "fallback: “blocking” in getStaticPaths but what do I have to do, to get proper 404 pages with urls that are not found?? What am I missing?
Thanks for your reply, it looks kinda similar on my end… so the 404 page should appear, I guess?
The demo site I talk about is: https://classy-starburst-255d72.netlify.app/
feel free to test any non-existing page
ah, it’s because one of your pages is /[slug]
so /lksjdflksdjl
would be mapped to it
Yes, that’s correct!
What would be the best workflow with that? Is there any option that non-existing slugs (which do not occur in my CMS-database) are getting re-routed to a 404-page? Or would I just style a dummy-page listing “item not found” or something like that?
Thank you so much for your help
If the CMS entry were valid, the queryCache
prop should be populated with data from the CMS. So you could peek in there; if there’s nothing related to the CMS entry, return a 404.
Alright I’m gonna try that. Thank you very much!!