Skip to content

Commit

Permalink
Merge pull request #238 from depromeet/fix/token-refresh
Browse files Browse the repository at this point in the history
token refresh 실패하면 로그인 페이지로 이동
  • Loading branch information
YOOJS1205 authored Feb 3, 2024
2 parents a71e051 + b59d77c commit 95f2fda
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/api/api-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import axios from 'axios';
import Cookies from 'js-cookie';

import { TOKEN_REFRESH_URL, LOGOUT_URL } from '@constants/endpoint';
import {
getTokenRefresh,
logout,
removeTokenAndMoveToLogin,
} from '@utils/auth';
import { getTokenRefresh, removeTokenAndMoveToLogin } from '@utils/auth';

type Method = 'get' | 'post' | 'put' | 'delete' | 'patch';

Expand Down Expand Up @@ -117,8 +113,8 @@ axiosInstance.interceptors.response.use(
}

// NOTE: 토큰 재발급 요청이 유효하지 않으면, 쿠키의 토큰을 삭제하고 로그아웃 처리. 로그인 페이지로 이동
if (config.url === TOKEN_REFRESH_URL && response.data.code === 401) {
logout();
if (config.url === TOKEN_REFRESH_URL && response.data.code === 400) {
removeTokenAndMoveToLogin();
}
},
);
Expand Down

0 comments on commit 95f2fda

Please sign in to comment.