目前我正在关注如何在 getInitialProps 中重定向用户的示例
https://github.com/zeit/next.js/wiki/Redirecting-in-%60getInitialProps%60
问题是,如果我想像这样返回 404,它将返回一个空白页面,而不是通常的 Next.js 404 错误页面。
context.res.writeHead(404)
context.res.end();
请注意,我知道使用 ExpressJs 和使用 statuscode 404 是可行的,但是,对于这个项目,我不允许使用 ExpressJs,所以我需要使用典型的 nodejs writeHead 来做到这一点。