_error.page.tsx 707 B

12345678910111213141516171819
  1. import type { JSX } from 'react';
  2. import type { NextPageContext } from 'next';
  3. import type { ErrorProps } from 'next/error';
  4. import NextError from 'next/error';
  5. export default function ErrorPage(props: ErrorProps): JSX.Element {
  6. return <NextError {...props} />;
  7. }
  8. // add getInitialProps to disable "https://nextjs.org/docs/messages/prerender-error"
  9. // Error: Export encountered errors on following paths:
  10. // /_error: /404
  11. // /_error: /500
  12. // see: https://github.com/vercel/next.js/issues/23568#issuecomment-814971318
  13. ErrorPage.getInitialProps = (ctx: NextPageContext) => {
  14. const { res, err } = ctx;
  15. const statusCode = res?.statusCode ?? err?.statusCode ?? 500;
  16. return { statusCode };
  17. };