From ca39fb5be934aa023986143f426e65962a68a978 Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Wed, 7 Aug 2024 17:39:16 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=84=9C=EB=B2=84=EC=97=90=EC=84=9C=20r?= =?UTF-8?q?efresh=EA=B0=B1=EC=8B=A0=20=EC=8B=A4=ED=8C=A8=ED=95=A0=EB=95=8C?= =?UTF-8?q?=20=EB=A1=9C=EA=B7=B8=EC=95=84=EC=9B=83=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/{index.ts => index.tsx} | 12 ++++++++++++ 1 file changed, 12 insertions(+) rename src/apis/{index.ts => index.tsx} (55%) diff --git a/src/apis/index.ts b/src/apis/index.tsx similarity index 55% rename from src/apis/index.ts rename to src/apis/index.tsx index ff10199..6bc8f21 100644 --- a/src/apis/index.ts +++ b/src/apis/index.tsx @@ -1,5 +1,6 @@ import { BASE_URL, DEV_AUTH_TOKEN } from '@/constants/environment'; import axios from 'axios'; +import AuthAccessGuard from '@/components/auth/guard/AuthAccessGuard'; const apiClient = axios.create({ baseURL: BASE_URL, @@ -7,6 +8,17 @@ const apiClient = axios.create({ withCredentials: true }); +apiClient.interceptors.response.use( + (response) => response, + async (error) => { + if (error.response.status === 401) { + sessionStorage.setItem('isLogin', 'false'); + return ; + } + return Promise.reject(error); + } +); + export function setAuthHeader() { if (DEV_AUTH_TOKEN) { apiClient.defaults.headers.common['Authorization'] = DEV_AUTH_TOKEN;