fix: add custom Pages Router _error page for 404/500 prerendering

Override default Next.js _error page that imports <Html> from
next/document, which fails during Docker build prerendering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
bipproduction
2026-03-06 11:35:48 +08:00
parent 5230a31942
commit d401ebb208

30
src/pages/_error.tsx Normal file
View File

@@ -0,0 +1,30 @@
import { NextPageContext } from "next";
function ErrorPage({ statusCode }: { statusCode?: number }) {
return (
<div
style={{
display: "flex",
alignItems: "center",
justifyContent: "center",
minHeight: "100vh",
backgroundColor: "#252A2F",
color: "white",
fontFamily: "Lato, sans-serif",
}}
>
<h1 style={{ fontSize: 24, fontWeight: 700 }}>
{statusCode === 404
? "404 - Halaman Tidak Ditemukan"
: "Terjadi Kesalahan"}
</h1>
</div>
);
}
ErrorPage.getInitialProps = ({ res, err }: NextPageContext) => {
const statusCode = res ? res.statusCode : err ? err.statusCode : 404;
return { statusCode };
};
export default ErrorPage;