Recently, one of our sites is having some weird behavior. Without any changes to the 500.js file, the following error occurs when a page throws a 500 error.
When you visit this page, an external fetch throws an error, resulting in the page to error out. I expect it to show the 500 error message on the .com domain.
I’m using next@14.2.15 with pages router and trailingSlash option in the next config is on and localeDetection is off. We use a middleware to internally route the example URL to /product/[...slug] . The site is proxied through Cloudflare to cache JSON files and monitor bots.
The error suggests that Next.js cannot find the 500.js file. Can you check the build output in .next/server/pages/ to ensure that the 500.js page is generated properly? Also, the redirection to .nl when an error occurs may point to an issue with the locale or how the domain routing is set up.
Let’s also ensure that your domain locale settings are correct in the Next.js config, and there are no unintended effects with locale fallback.
Are your Cloudflare logs for any requests to the .com domain resulting in 301/302 redirects, particularly around the 500 error pages?
The 500.js file does exist in the build output on the given path, as well as a JSON and HTML file in each locale folder. That is for a local build. The output folder in Vercel only has a 500 file for each locale folder.
Given that the 500.js file is present in the Vercel output but still causing a missing module error, there could be possibly a routing or locale-specific issue affecting error page handling?
Since you’re using middleware to handle the /product/[...slug] routing, can you try logging its behavior during error scenarios? I wonder if the middleware is affecting locale-specific paths for the 500 page.
Also I assume, 500.js for en is served without any disturbance caused from custom routing rules.
Can you also check if any caching rules or edge functions on Cloudflare could be interfering with locale handling?
I totally understand how tiresome troubleshooting might be but it will all be totally worth it once we found the root cause!
Also, given that Vercel Team is so helpful, I believe they will be able to help us get to the root of this and make it work as expected!
We are using the pages router and using i18n config. Our middleware does not use the locale to reroute or redirect requests.
Logging the errors locally works just fine.