Custom 500 page not rendering
Unanswered
Laughing Gull posted this in #help-forum
Laughing GullOP
https://nextjs.org/docs/pages/building-your-application/configuring/error-handling#handling-server-errors
https://nextjs.org/docs/pages/building-your-application/data-fetching/get-server-side-props#does-getserversideprops-render-an-error-page
According nextjs a pages/500.js file should be whats rendered durring a server error. And according to their docs throwing an error in getServerSideProps should show the pages/500.js file.
There doesn't seem to be a lot of talk about this issue, i can't find a good solution. I found some github discussions about it but no fix.
Am i missing something?
https://nextjs.org/docs/pages/building-your-application/data-fetching/get-server-side-props#does-getserversideprops-render-an-error-page
According nextjs a pages/500.js file should be whats rendered durring a server error. And according to their docs throwing an error in getServerSideProps should show the pages/500.js file.
export async function getServerSideProps(context) {
const contentfulClient = createContentfulClient();
const { req } = context;
const { locale = 'en' } = req;
const releaseNotes = // client side stuff
context.res.statusCode = 500;
throw new Error('Internal Server Error');
return {
props: {
releaseNotes,
},
};
}There doesn't seem to be a lot of talk about this issue, i can't find a good solution. I found some github discussions about it but no fix.
Am i missing something?
5 Replies
iirc all error pages are only applied in prod mode and superseded by the default nextjs error overlay in dev mode
Laughing GullOP
I built and then ran yes