From b98e4a23a91bbe90047a7c6cf2b3968bd43509f8 Mon Sep 17 00:00:00 2001 From: Nathaniel Tampus Date: Mon, 6 Mar 2023 17:25:15 +0800 Subject: [PATCH] redirect on client for 404 --- client/src/pages/404.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/client/src/pages/404.tsx b/client/src/pages/404.tsx index 3f8136e..4250fff 100644 --- a/client/src/pages/404.tsx +++ b/client/src/pages/404.tsx @@ -1,12 +1,14 @@ -export default function NotFound() {} +import { useRouter } from "next/router"; +import { useEffect } from "react"; // Temporary. Move to app/ directory when it's supported -export function getStaticProps() { - return { - redirect: { - destination: "/", - permanent: true - } - }; +export default function NotFound() { + const router = useRouter(); + + useEffect(() => { + router.replace("/"); + }); + + return null; }