Skip to content
This repository was archived by the owner on Jun 28, 2025. It is now read-only.

Commit 09dcf0c

Browse files
author
Manuel Proß
committed
feat(web): add custom 500 error page
1 parent 7afee2a commit 09dcf0c

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

web/src/app/error/500/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Custom500() {
2+
return <h1 className="h1">500 - Internal server error</h1>;
3+
}

web/src/app/not-found.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Link from "next/link";
2+
3+
export default function NotFound() {
4+
return (
5+
<div>
6+
<h1 className="h1">Resource not found!</h1>
7+
<Link className="link" href="/">
8+
Return Home
9+
</Link>
10+
</div>
11+
);
12+
}

web/src/app/page.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ import useSWR from "swr";
33
import Hero from "@/components/Strapi/Sections/HeroSection";
44
import PageContent from "@/components/Strapi/Sections/Content";
55
import { PageAttributes, Routes } from "@/types/strapi";
6+
import Error from "next/error";
7+
import { redirect } from "next/navigation";
68

79
const fetcher = (url: string) => fetch(url).then(res => res.json() as Promise<PageAttributes>);
810

911
export default function Home() {
10-
const { data } = useSWR(`/api/${Routes.homepage}`, fetcher);
12+
const { data, error } = useSWR<PageAttributes, Error>(`/api/${Routes.homepage}`, fetcher);
13+
14+
if (error) {
15+
redirect("/error/500");
16+
}
1117

1218
return (
1319
<main className="pb-12">

0 commit comments

Comments
 (0)