最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论