Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes 404 no longer returned when error with code ENOENT is thrown. #11480

Closed
wants to merge 8 commits into from
11 changes: 8 additions & 3 deletions packages/next/next-server/server/next-server.ts
Expand Up @@ -1238,9 +1238,14 @@ export default class Server {
}
}
} catch (err) {
this.logError(err)
res.statusCode = 500
return await this.renderErrorToHTML(err, req, res, pathname, query)
if (err && err.code === 'ENOENT') {
res.statusCode = 404
return await this.renderErrorToHTML(null, req, res, pathname, query)
} else {
this.logError(err)
res.statusCode = 500
return await this.renderErrorToHTML(err, req, res, pathname, query)
}
}

res.statusCode = 404
Expand Down