diff --git a/src/app/informations/write/page.tsx b/src/app/informations/write/page.tsx index 5cbb59cc..c8eba1a0 100644 --- a/src/app/informations/write/page.tsx +++ b/src/app/informations/write/page.tsx @@ -1,6 +1,8 @@ import PagePath from "@/components/common/PagePath"; import InformationEditorContainer from "@/containers/informations/write/InformationEditorContainer"; import { Metadata } from "next"; +import { cookies } from "next/headers"; +import { redirect } from "next/navigation"; export const metadata: Metadata = { title: "정보 등록하기", @@ -8,6 +10,11 @@ export const metadata: Metadata = { }; export default function page() { + const cookie = cookies().get("access_token"); + if (!cookie) { + redirect("/auth/signin"); + } + return (
- {`${data.createdDate}`} + {`${new Date(data.createdDate).toLocaleDateString()}`}
- {`${data.createdDate}`} + {`${new Date(data.createdDate).toLocaleDateString()}`}
diff --git a/src/containers/common/HeaderContainer.tsx b/src/containers/common/HeaderContainer.tsx index 24c60e5e..681bedfc 100644 --- a/src/containers/common/HeaderContainer.tsx +++ b/src/containers/common/HeaderContainer.tsx @@ -45,13 +45,13 @@ const HeaderContainer = () => { // 자동 로그인 const login = async () => { const data = await fetchWithAuth("/api/auth/user"); - if (data.status == 200) { - data.json().then((res: userResponseDto) => { - authStore.setUser(res); - }); - } + if (data.status == 200) { + data.json().then((res: userResponseDto) => { + authStore.setUser(res); + }); + } }; - login(); + login(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []);