We have a route that makes a request to the api, if successful, is redirected, but if not and the api returns with a 500 internal server error, we would like to force a redirect to our 404 pg.
I’ve tried adding this to the catch block:
catch (e) {
console.log(e);
await renderNextPage('/404', res);
}
and it worked as expected locally, but when pushed to our default env. I got a 500 status with error: An unexpected error occurred while processing the request with next.js. (page="/404")
Any ideas on other ways to do this?