diff --git a/front/src/hooks/useLogout.tsx b/front/src/hooks/useLogout.tsx index 5ac3b65..3220551 100644 --- a/front/src/hooks/useLogout.tsx +++ b/front/src/hooks/useLogout.tsx @@ -2,8 +2,6 @@ import cookie from 'react-cookies'; const useLogout = () => { window.open(`/api/auth/logout`, '_self'); - cookie.remove('access_token'); - cookie.remove('refresh_token'); cookie.remove('loggedin'); window.location.replace('/'); }; diff --git a/front/src/pages/Intro/Intro.tsx b/front/src/pages/Intro/Intro.tsx index 5f62f3f..7263e8b 100644 --- a/front/src/pages/Intro/Intro.tsx +++ b/front/src/pages/Intro/Intro.tsx @@ -26,7 +26,7 @@ const Intro = () => { useEffect(() => { setMessageList(mockData.snowball_data.message_list as Array); - cookie.load('access_token') ? navigate('/main') : null; + cookie.load('loggedin') ? navigate('/main') : null; }, [setMessageList, navigate]); return ( diff --git a/front/src/pages/Main/Main.tsx b/front/src/pages/Main/Main.tsx index c03688e..b8fa54d 100644 --- a/front/src/pages/Main/Main.tsx +++ b/front/src/pages/Main/Main.tsx @@ -1,6 +1,7 @@ import { useEffect, useRef, useContext, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import axios from 'axios'; +import cookie from 'react-cookies'; import styled from 'styled-components'; import { Loading } from '@utils'; import { useLogout } from '@hooks'; @@ -104,6 +105,12 @@ const Main = () => { useEffect(() => { // saveCookie(); + + if (!cookie.load('loggedin')) { + navigate('/'); + return; + } + axios .get('/api/user', { withCredentials: true // axios 쿠키 값 전달