Skip to content

Commit

Permalink
fix(vercel#36855/vercel#30300): export 404.html correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed May 14, 2022
1 parent 2ed6aa3 commit e5f909a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/next/export/index.ts
Expand Up @@ -418,13 +418,20 @@ export default async function exportApp(
})
)

if (
!options.buildExport &&
!exportPathMap['/404'] &&
!exportPathMap['/404.html']
) {
exportPathMap['/404'] = exportPathMap['/404.html'] = {
page: '/_error',
// only add missing 404 page when `buildExport` is false
if (!options.buildExport) {
// only add missing /404 if not specified in `exportPathMap`
if (!exportPathMap['/404']) {
exportPathMap['/404'] = { page: '/_error' }
}

/**
* exports 404.html for backwards compat
* E.g. GitHub Pages, GitLab Pages, Cloudflare Pages, Netlify
*/
if (!exportPathMap['/404.html']) {
// alias /404.html to /404 to be compatible with custom 404 / _error page
exportPathMap['/404.html'] = exportPathMap['/404']
}
}

Expand Down

0 comments on commit e5f909a

Please sign in to comment.