Merge pull request 'fix: pages/_error and _document for build' (#23) from fix/pages-error-handler into main

This commit was merged in pull request #23.
This commit is contained in:
2026-04-01 04:56:36 +00:00
2 changed files with 26 additions and 0 deletions

12
pages/_document.tsx Normal file
View File

@@ -0,0 +1,12 @@
import { Html, Head, Main, NextScript } from 'next/document';
export default function Document() {
return (
<Html lang="en">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
);
}

14
pages/_error.tsx Normal file
View File

@@ -0,0 +1,14 @@
// Custom error page — prevents Html import issue in Next.js pages router
export default function Error({ statusCode }: { statusCode?: number }) {
return (
<div style={{ padding: '2rem', fontFamily: 'sans-serif' }}>
<h1>{statusCode || 'Error'}</h1>
<p>{statusCode === 404 ? 'Page not found' : 'An error occurred'}</p>
</div>
);
}
Error.getInitialProps = ({ res, err }: any) => {
const statusCode = res ? res.statusCode : err ? err.statusCode : 404;
return { statusCode };
};