diff --git a/src/pages/_error.tsx b/src/pages/_error.tsx new file mode 100644 index 0000000..62e1b9a --- /dev/null +++ b/src/pages/_error.tsx @@ -0,0 +1,27 @@ +import MainContainer from '@/components/shared/MainContainer'; +import { NextPageContext } from 'next'; +import { useRouter } from 'next/router'; + +function Error({ statusCode }: { statusCode?: number }) { + const router = useRouter(); + return ( + +
+ {statusCode} 에러가 발생했습니다. +
+
router.replace('/')} + className="cursor-pointer mt-16 mx-auto rounded-lg w-[360px] h-12 bg-space-purple text-white text-xl font-semibold flex items-center justify-center"> + 홈으로 +
+
+ ); +} + +Error.getInitialProps = ({ res, err }: NextPageContext) => { + const statusCode = res ? res.statusCode : err ? err.statusCode : 404; + + return { statusCode }; +}; + +export default Error;