Took a bit to figure out what was going on when i reached this issue. The issue appears to be that Nextjs SSR handler function is unable to fetch the generated 404 and 500 pages when the site access controls are set to “basic password”
We were getting the following error in the function logs:
MissingStaticPage [Error]: Failed to load static file for page: /404 Failed to download https://staging.domain.com/404.html: 401 Unauthorized
Seems this may be an issue when enabling password protection before you deploy the custom error pages in Next.js.
A workaround we have found is to disable password protection and load the 404 page. Then re-enable password protection and it seems to work as expected.
Hopefully it’s just a one off bug in current release of the Next.js SSR plugin. this helps someone save time debugging.
This was the cause and “solution” for us too. With Netlify’s Basic Password Protection enabled, we got a 500 server error and the same “MIssingStaticPage” error in the logs. After turning off password protection, we could then visit an invalid URL and view our custom 404 page as expected (generated from /pages/404.tsx), as well as on subsequent visits to that same URL after password-protection was re-enabled.