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) {