Skip to content

Commit

Permalink
fix: 서버에서 refresh갱신 실패할때 로그아웃 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene028 committed Aug 7, 2024
1 parent 2e70d63 commit ca39fb5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/apis/index.ts → src/apis/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
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,
headers: { 'Content-Type': 'application/json' },
withCredentials: true
});

apiClient.interceptors.response.use(
(response) => response,
async (error) => {
if (error.response.status === 401) {
sessionStorage.setItem('isLogin', 'false');
return <AuthAccessGuard />;
}
return Promise.reject(error);
}
);

export function setAuthHeader() {
if (DEV_AUTH_TOKEN) {
apiClient.defaults.headers.common['Authorization'] = DEV_AUTH_TOKEN;
Expand Down

0 comments on commit ca39fb5

Please sign in to comment.