// Minimal Pages Router _error override — prevents Next.js from using its
// default implementation that imports next/document, which breaks App Router
// production builds with next-auth v5 beta.
//
// Next.js always prerenders /_error even in App Router apps. This stub is
// enough to satisfy the prerender without hitting the Html-outside-_document
// error.
function ErrorPage({ statusCode }: { statusCode?: number }) {
  return <p>Erro {statusCode ?? 'desconhecido'}</p>;
}

ErrorPage.getInitialProps = ({ res, err }: { res?: { statusCode: number }; err?: { statusCode: number } }) => {
  const statusCode = res?.statusCode ?? err?.statusCode ?? 500;
  return { statusCode };
};

export default ErrorPage;
