From 54448718badd3a5630998e4606a5f65f2275ddc2 Mon Sep 17 00:00:00 2001 From: happppi <102276917+hhbb0081@users.noreply.github.com> Date: Wed, 27 Mar 2024 03:11:16 +0900 Subject: [PATCH] =?UTF-8?q?Style:=20=EC=A3=BC=EC=84=9D=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/util/commonApis.jsx | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/src/util/commonApis.jsx b/src/util/commonApis.jsx index 062dfb3..08b913b 100644 --- a/src/util/commonApis.jsx +++ b/src/util/commonApis.jsx @@ -1,5 +1,4 @@ import axios from "axios"; -import { useNavigate } from "react-router-dom"; const commonApis = axios.create({ baseURL: process.env.REACT_APP_API_ROOT + "/api/v1", @@ -26,38 +25,14 @@ commonApis.interceptors.response.use( (res) => { return res }, (err) => { const { - // config, + config, response, } = err; - const navigate = useNavigate(); console.log(err); // access token 만료 시 if (response?.status === 403) { - navigate("/"); - // axios.get(process.env.REACT_APP_API_ROOT + "/api/v1/refresh/token", { - // withCredentials: true - // }) - // .then((res) => { - // console.log(res); - // const accessToken = res.data.accessToken; - // // console.log('accessToken: ', accessToken); - // if(accessToken){ - // console.log("access token 재설정!"); - // console.log(accessToken); - // localStorage.setItem('accessToken', accessToken); - // localStorage.setItem("expiredTime", moment().add(1, "days").format("yyyy-MM-DD HH:mm:ss")) - // axios.defaults.headers.common.Authorization = "Bearer " + accessToken; - // config.headers.common["Authorization"] = "Bearer " + accessToken; - // } - // return axios(config); - // }) - // .catch((e) => { - // if (e?.response?.status === 401 || e?.response?.status === 403){ - // // 로그인 페이지로 이동 - // window.location.href = "/login"; - // } - // }); - // return config; + window.location.href = "/login"; + return config; } return Promise.reject(err); }