We have a Custom404 page in our pages router that includes a getStaticProps function. This component has been working since forever, but recently it has started to throw the 500 page instead when a dynamic page /[id] with getServerSideProps returns:
{ notFound: true }
The logs show this error in Vercel:
⨯ [Error: Failed to load static file for page: /404 ENOENT: no such file or directory, open ‘/var/task/.next/server/pages/404.html’]
How ever if I go directly to visit my website/404 the page renders properly.
Additionally, looking at the build logs, for some reason I can see that the /404 page has been “(Static) prerendered as static content” instead of “prerendered as static HTML (uses getStaticProps)” like the other 500 page, when they both include getStaticProps, not sure if this has to do with the issue.
I am currently on Next 15.1.0.