diff --git a/frontend/src/shared/remotes/index.ts b/frontend/src/shared/remotes/index.ts index fd8bb7f23..7472945a1 100644 --- a/frontend/src/shared/remotes/index.ts +++ b/frontend/src/shared/remotes/index.ts @@ -1,4 +1,3 @@ -import { useNavigate } from 'react-router-dom'; import ROUTE_PATH from '@/shared/constants/path'; export interface ErrorResponse { @@ -9,8 +8,8 @@ export interface ErrorResponse { const { BASE_URL } = process.env; const fetcher = async (url: string, method: string, body?: unknown) => { - // eslint-disable-next-line react-hooks/rules-of-hooks - const navigate = useNavigate(); + const loginRedirectUrl = `${process.env.BASE_URL}${ROUTE_PATH.LOGIN}`?.replace(/api\/?/, ''); + const accessToken = localStorage.getItem('userToken'); const headers: Record = { @@ -38,7 +37,8 @@ const fetcher = async (url: string, method: string, body?: unknown) => { if (response.status === 401) { localStorage.removeItem('userToken'); - navigate(ROUTE_PATH.LOGIN); + //TODO: 해당 부분 router-dom으로 해결 가능한지 확인해야함. + window.location.href = loginRedirectUrl; } if (!response.ok) {