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

404 page is rendered in development #7286

Closed
StarpTech opened this issue May 9, 2019 · 3 comments
Closed

404 page is rendered in development #7286

StarpTech opened this issue May 9, 2019 · 3 comments

Comments

@StarpTech
Copy link
Contributor

Bug report

Describe the bug

Hello, I use a custom _error page with different markup for 404 and 500 pages. When I run into a 404 next.js is trying to render my page but the layout is broken. It seems that the page wasn't build correctly.

After reading the docs

404 or 500 errors are handled both client and server side by a default component error.js. If you wish to override it, define a _error.js in the pages folder:
warning The pages/_error.js component is only used in production. In development you get an error with call stack to know where the error originated from. warning

I expect that no 404 page is rendered. As a workaround to NOT see a broken 404 page I have to do:

  /**
   * warning The pages/_error.js component is only used in production.
   * In development you get an error with call stack to know where the error originated from. warning
   * https://github.com/zeit/next.js#custom-error-handling
   */
  render() {
    if (process.env.NODE_ENV !== 'production') return <NextError statusCode={this.props.statusCode} />;
    if (this.props.statusCode === 404) return this.render404();
    return this.render500();
  }

is that the expected behaviour? In production everything works fine

Expected behavior

As documented no _error should be rendered in development.

System information

  • OS: Ubuntu
  • Browser: Chrome
  • Version of Next.js: 8.1.0
@timneutkens
Copy link
Member

Please provide a reproduction.

@Bournegit
Copy link

Followed Getting Started

After creating pages/index.js .

Still 404 page is appearing .

dependencies": {
"next": "^8.1.0",
"react": "^16.8.6",
"react-dom": "^16.8.6"
}

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants