From c0b3839cb7f43f46bb8089ae5876adfc4909cc0c Mon Sep 17 00:00:00 2001 From: hyeseon han Date: Mon, 19 Feb 2024 00:23:51 +0900 Subject: [PATCH] =?UTF-8?q?hotfix:=20localStorage=20=ED=99=95=EC=9D=B8?= =?UTF-8?q?=EC=8B=9Cserver=20render=EC=8B=9C=20window=20=EA=B0=9D=EC=B2=B4?= =?UTF-8?q?=20=EC=97=AC=EB=B6=80=20=EC=A1=B0=EA=B1=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/templates/withLogin.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/templates/withLogin.tsx b/src/components/templates/withLogin.tsx index 170957f..9017f5d 100644 --- a/src/components/templates/withLogin.tsx +++ b/src/components/templates/withLogin.tsx @@ -1,10 +1,14 @@ import React, { useEffect } from 'react'; + import { useRouter } from 'next/router'; const withLogin = (InnerComponent: React.FC) => { return () => { const router = useRouter(); - const token = localStorage.getItem('accessToken'); + const token = + typeof window !== 'undefined' + ? localStorage.getItem('accessToken') + : null; const redirectToLogin: () => Promise = async () => { if (!token) {