How to actually redirect to a 404 error page in getServerSideProps #16511
Unanswered
leo-petrucci
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I'm currently struggling with error pages, specifically 404 errors. At the moment if a page that does not exist in my application is requested, the user is directed to /pages/404.js, as they should.
However, if I have a catch-all route like /pages/posts/[slug].js, I am unable to show the same 404 page I mentioned above. I've looked all over but for some reason there seems to be absolutely no information on how to achieve this.
Resources I found that didn't help:
At the moment I'm able to return a 404 error, but this is displayed as the browser's default error which doesn't look very professional. This is the code for achieving that:
Is there any way to both return a 404 state as well as showing a custom error page?
Beta Was this translation helpful? Give feedback.
All reactions