Open
Conversation
12234538
reviewed
Apr 11, 2026
| }); | ||
|
|
||
| // accessToken 만료 시 재발급 인터셉터 등록 | ||
| axiosInstance.interceptors.request.use((config) => { |
There was a problem hiding this comment.
저는 accessToken 만료 시 재발급을 안 해놓은 거 같은데 이렇게 재발급 요청도 따로 넣을 수 있군요! 참고하겠습니다! 코드가 깔끔해서 읽기 너무 좋아요!
qkrdmsthff
approved these changes
Apr 13, 2026
Collaborator
qkrdmsthff
left a comment
There was a problem hiding this comment.
LGTM 카사 제가 바빠서 이번 피드백은 늦고, 자세하게 못해드렸네요 ㅠㅠ 5주차부터 다시 열심히 달아드릴게요! 수고 많으셨습니다
Comment on lines
+18
to
+37
| axiosInstance.interceptors.response.use( | ||
| (response) => response, | ||
| async (error) => { | ||
| const status = error.response?.status; | ||
| if (status === 401) { | ||
| const isLoginRequest = error.config?.url?.includes("signin"); | ||
| if (isLoginRequest) return Promise.reject(error); | ||
|
|
||
| const refreshToken = localStorage.getItem("refreshToken"); | ||
| if (refreshToken) { | ||
| const response = await refresh({ refresh: refreshToken }); | ||
| localStorage.setItem("accessToken", response.data.accessToken); | ||
| localStorage.setItem("refreshToken", response.data.refreshToken); | ||
| return axiosInstance(error.config); | ||
| } | ||
| window.location.href = "/login"; | ||
| } else if (status === 500) { | ||
| // 서버 에러 | ||
| alert("서버 오류가 발생했습니다. 잠시 후 다시 시도해주세요."); | ||
| } |
Collaborator
There was a problem hiding this comment.
AccessToken 재발급 로직을 아주 잘 짜셨네요 카사!! 멋있습니다.
하지만, 현재 코드에서 여러 개의 API가 동시에 401 에러를 뱉는 경우,
페이지 로드 시 API 3개를 동시에 호출했는데 토큰이 만료되어 있었다면, refresh 함수가 3번 호출되고 localStorage 에 토큰이 꼬일 수 있습니다!
isRefreshing 플래그와 refreshSubscribers 큐를 만들어 첫 번째 요청만 refresh를 수행하고, 나머지 요청은 대기시켰다가 재발급 후 한꺼번에 실행해보는 방법을 적용해봐도 좋겠네요 ㅎㅎ 수고많으셨습니다
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✅ 워크북 체크리스트
✅ 컨벤션 체크리스트
📌 주안점
미션 1은 3주차에 이미 진행한 내용으로 판단하여 별도로 업로드하지 않았습니다.