Custom error page
Unanswered
Satin Angora posted this in #help-forum
Satin AngoraOP
Hi, i am trying to find a way of how i can in dev mode replace the runtime error modal with my custom error page based on the status code set when i am throwing error (in client):
throw new NotFoundError('This is an error');
throw new BadRequestError('This is an error');
throw new ForbiddenError('This is an error');
etc.
I have tried to add a custom page called error.js into possibly every directory in the project, and i was never able to get that custom page working.
thanks !
throw new NotFoundError('This is an error');
throw new BadRequestError('This is an error');
throw new ForbiddenError('This is an error');
etc.
I have tried to add a custom page called error.js into possibly every directory in the project, and i was never able to get that custom page working.
thanks !
4 Replies
Satin AngoraOP
the error page is just never picked up
Spectacled bear
jummm try testing in production build:
it's a bit tedious (in order to need to make a build on every change) but in this way you could test you error pages.
NODE_ENV=production npm run build && npm start it's a bit tedious (in order to need to make a build on every change) but in this way you could test you error pages.
Satin AngoraOP
Hi, thanks for the answer. That kind of helped. But it says internal server error for SSR pages when it should say something like not found and nothing for exception thrown in client component.
Satin AngoraOP
I have just tried with new nextjs installation and it worked fine. I suppose its because of the way i handle subdomains, something just stops working