Skip to content

Commit

Permalink
feat: 토큰 만료 시 재로그인 유도
Browse files Browse the repository at this point in the history
  • Loading branch information
lydiacho committed Oct 31, 2024
1 parent fc10427 commit e7d1717
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/utils/apis/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getToken } from '@utils/storage';
import { clearStorage, getToken } from '@utils/storage';
import * as _axios from 'axios';

const baseUrl = import.meta.env.VITE_APP_API_BASE_URL;
Expand Down Expand Up @@ -29,3 +29,15 @@ authAxios.interceptors.request.use(
return Promise.reject(error);
}
);

authAxios.interceptors.response.use(
(res) => res,
async (err) => {
if (err.response.data.code === '40076') {
alert(`세션이 만료되었습니다.\n다시 로그인해주세요.`);
clearStorage();
location.href = '/';
}
return Promise.reject(err);
}
);

0 comments on commit e7d1717

Please sign in to comment.