Skip to content

Commit

Permalink
Merge pull request #227 from SystemConsultantGroup/fix/axios-interceptor
Browse files Browse the repository at this point in the history
[FIX] Interceptor에 있는 오류 if문 순서 수정
  • Loading branch information
2tle authored Feb 11, 2025
2 parents 4aa7237 + bdfba15 commit d839261
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/utils/CommonAxios/CommonAxios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ CommonAxios.interceptors.response.use(
return response;
},
async function (error) {
// 401: 인증 실패 → 로그인 페이지(또는 메인)로 리다이렉트
// if (error.response?.status === 401) {
// redirect("/");
// return Promise.reject(error);
// }

// 특정 에러 코드(4002, 3001)로 로그아웃이 필요한 상황

if (
error.response?.data?.code === 4002 ||
error.response?.data?.code === 3001 ||
Expand All @@ -41,7 +34,10 @@ CommonAxios.interceptors.response.use(
})
.catch((error) => console.error("Logout failed:", error));
}

else if (error.response?.status === 401) { // 401: 인증 실패 → 로그인 페이지(또는 메인)로 리다이렉트
redirect("/");
return Promise.reject(error);
}
return Promise.reject(error);
}
);

0 comments on commit d839261

Please sign in to comment.