next export's defaultPathMap contains /_error which is not supported as error page by most browsers. What however is supported is 404.html.
Updating https://github.com/zeit/next.js/blob/canary/server/export.js#L34
To have the following statement:
if(page === '/_error') {
defaultPathMap['404'] = { page }
continue
}
This will make next export export 404.html with the contents of /_error
The alternative is doing this manually in exportPathMap
module.exports = {
exportPathMap(defaultPathMap) {
defaultPathMap['404'] = defaultPathMap['/_error']
return defaultPathMap
}
}
Feature request originated on this spectrum.chat thread: https://spectrum.chat/thread/f765b794-9aa9-4edc-b549-6de2268847e5
cc @kylemh as you surfaced this on zeit.chat
Claiming (if that's a thing)
A test should be added here https://github.com/zeit/next.js/blob/canary/test/integration/static/test/ssr.js#L6 for this new behavior
You can run the specific test suite using yarn testonly --testPathPattern "static" -t "Render via SSR" or when you added the test replace Render via SSR with <your test name>
I'm expecting this is because the files are exported in a subdir 404/index.html. Let's fix that.
@timneutkens I'll dive in next week to see If I can get to it on my own 馃憤
I imagine it'll be some sort of conditional logic around here: https://github.com/zeit/next.js/blob/canary/export/index.js#L124
Correct
I'm having this problem too, we change the _error.js code to a better-looking page. So, we just send our NextJS app to production using Zeit Now, and everything works BUT the 404 error page, I don't know how, but it's loading the default error page, but that page doesn't exist anymore, it should load the actual _error.js and it's not happening, any idea why is happening?
Lot of context on this issue and a resolution for you here: https://github.com/zeit/now-builders/issues/234
Cross posting for visibility, thanks @kylemh!
"routes": [
// ...otherRoutes,
{ "handle": "filesystem" },
{ "src": "/.*", "dest": "/_error" }
],
_Originally posted by @kylemh in https://github.com/zeit/now-builders/issues/234#issuecomment-497031992_
Most helpful comment
Correct