fix: add pages/_error and _document to fix Html import in build
This commit is contained in:
14
pages/_error.tsx
Normal file
14
pages/_error.tsx
Normal 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 };
|
||||
};
|
||||
Reference in New Issue
Block a user