Next.js: Rendering an error, doesnt have correct http codes

Created on 14 Jul 2020  路  2Comments  路  Source: vercel/next.js

Bug report

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

  1. Clone the repo https://github.com/maraisr/nextjs-repro-repo
  2. run yarn
  3. run yarn next dev
  4. inspect DevTools, and notice the document is 200 and not 404

The same happens under a build/start.

Expected behavior

Have the response be 404.

System information

  • OS: Windows
  • Browser: Firefox
  • Version of Next: 9.4.4
  • Version of Node.js: 14.0.0

Additional context

Followed: https://nextjs.org/docs/advanced-features/custom-error-page#customizing-the-error-page

story

Most helpful comment

https://github.com/maraisr/nextjs-repro-repo/blob/main/pages/index.js#L11

The Error component is just a React component that renders something based on properties. It does not have any magic behavior.

We're planning to add something that allows for returning "this is a 404" to getStaticProps/getServerSideProps though which should cover your use case. added this issue to my list to ping when the RFC is done for that.

Related issues:

All 2 comments

https://github.com/maraisr/nextjs-repro-repo/blob/main/pages/index.js#L11

The Error component is just a React component that renders something based on properties. It does not have any magic behavior.

We're planning to add something that allows for returning "this is a 404" to getStaticProps/getServerSideProps though which should cover your use case. added this issue to my list to ping when the RFC is done for that.

Related issues:

Closing in favor of above two issues.

Was this page helpful?
0 / 5 - 0 ratings