next.js - How can I access request headers in my custom 404 page (with the pages router)? - Stack Overflow

I'm working on a Next.js project using the pages router, and the official documentation shows that

I'm working on a Next.js project using the pages router, and the official documentation shows that this can be done by creating a page at pages/404.tsx:

export default function Custom404() {
  return <h1>404 - Page Not Found</h1>
}

How can I access the HTTP request headers here? Normally I would do it with the getServerSideProps, but the documentation says 404.js Cannot Have getInitialProps/getServerSideProps.

I just want to get the "accept-language" header so I the display text can be localized.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745670712a4639386.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信