fix: add custom 404 and global error pages for Docker build
Create not-found.tsx and global-error.tsx to prevent Next.js from falling back to legacy Pages Router _error pages during static generation, which fail with useContext null in Docker. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
41
src/app/global-error.tsx
Normal file
41
src/app/global-error.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
"use client";
|
||||
|
||||
export default function GlobalError({
|
||||
reset,
|
||||
}: {
|
||||
error: Error & { digest?: string };
|
||||
reset: () => void;
|
||||
}) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body
|
||||
style={{
|
||||
backgroundColor: "#252A2F",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
minHeight: "100vh",
|
||||
gap: 16,
|
||||
fontFamily: "Lato, sans-serif",
|
||||
color: "white",
|
||||
}}
|
||||
>
|
||||
<h2>Terjadi Kesalahan</h2>
|
||||
<button
|
||||
onClick={() => reset()}
|
||||
style={{
|
||||
padding: "8px 16px",
|
||||
borderRadius: 4,
|
||||
border: "1px solid #ccc",
|
||||
background: "transparent",
|
||||
color: "white",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
>
|
||||
Coba Lagi
|
||||
</button>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
24
src/app/not-found.tsx
Normal file
24
src/app/not-found.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Box, Text, Button } from "@mantine/core";
|
||||
import Link from "next/link";
|
||||
|
||||
export default function NotFound() {
|
||||
return (
|
||||
<Box
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
minHeight: "100vh",
|
||||
gap: 16,
|
||||
}}
|
||||
>
|
||||
<Text size="xl" fw={700} c="white">
|
||||
404 - Halaman Tidak Ditemukan
|
||||
</Text>
|
||||
<Button component={Link} href="/" variant="light">
|
||||
Kembali ke Beranda
|
||||
</Button>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user