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

False alarm "You have added a custom /_error page without a custom /404" #12060

Closed
hems opened this issue Apr 20, 2020 · 1 comment · Fixed by #12061
Closed

False alarm "You have added a custom /_error page without a custom /404" #12060

hems opened this issue Apr 20, 2020 · 1 comment · Fixed by #12061

Comments

@hems
Copy link

hems commented Apr 20, 2020

Bug report

I'm getting the error "Warning: You have added a custom /_error page without a custom /404 page. This prevents the 404 page from being auto statically optimized.
See here for info: https://err.sh/next.js/custom-error-no-custom-404" even tough i have both files in my pages/ folder.

Describe the bug

When running it locally with "yarn dev" i get that error even tough both files exists.

To Reproduce

# src/pages/404.js
import SEO from '../components/app/SEO'

function NotFound(props) {
  return (
    <>
      <SEO page='not-found' />
      <h1>Page Not Found</h1>
    </>
  );
}

export default NotFound;
# src/pages/_error.js
function Error({ statusCode }) {
  return (
    <>
      {statusCode
        ? `An error ${statusCode} occurred on server`
        : 'An error occurred on client'}
    </>
  )
}

Error.getInitialProps = ({ res, err }) => {
  const statusCode = res ? res.statusCode : err ? err.statusCode : 404
  return { statusCode }
}

export default Error

Expected behavior

Not get the error

System information

  • OS: OSX 10.12
  • Version of Next.js: 9.3.4
  • Version of Node.js: 12.4
@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 30, 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

Successfully merging a pull request may close this issue.

2 participants