Skip to content

Commit

Permalink
feat : 일반 에러 페이지 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
banhogu committed Jun 21, 2024
1 parent 2b4078c commit 721c916
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/pages/_error.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<MainContainer>
<div className="flex items-center justify-center text-3xl font-extrabold">
{statusCode} 에러가 발생했습니다.
</div>
<div
onClick={() => 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">
홈으로
</div>
</MainContainer>
);
}

Error.getInitialProps = ({ res, err }: NextPageContext) => {
const statusCode = res ? res.statusCode : err ? err.statusCode : 404;

return { statusCode };
};

export default Error;

0 comments on commit 721c916

Please sign in to comment.