Skip to content

Commit 2f63d48

Browse files
authored
Merge pull request #163 from prgrms-web-devcourse-final-project/fix/162-reissue-token
[fix] 토큰 재발급 실패 시 에러 처리
2 parents c6352ef + 0a3cdf2 commit 2f63d48

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/apis/auth.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export const reissueToken = async () => {
3535
if (code === 200) {
3636
useAuthStore.getState().setAccessToken(accessToken); // 토큰 전역 상태 저장
3737
console.log('토큰 재발급 성공:', accessToken);
38+
} else {
39+
throw new Error('토큰 재발급 실패');
3840
}
3941
return data;
4042
};

src/apis/axios.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ axiosInstance.interceptors.response.use(
4040
await reissueToken(); // 토큰 재발급 요청
4141
return axiosInstance(originalRequest); // 원래 요청 다시 시도
4242
} catch (error) {
43+
useAuthStore.getState().logout();
4344
useAuthStore.persist.clearStorage();
4445
console.error('AT 토큰 재발급 실패:', error);
4546

0 commit comments

Comments
 (0)