Skip to content

[4주차/카사] 워크북 제출합니다.#44

Open
jjeunv wants to merge 3 commits intoUMC-Inha:카사/mainfrom
jjeunv:main
Open

[4주차/카사] 워크북 제출합니다.#44
jjeunv wants to merge 3 commits intoUMC-Inha:카사/mainfrom
jjeunv:main

Conversation

@jjeunv
Copy link
Copy Markdown

@jjeunv jjeunv commented Apr 8, 2026

✅ 워크북 체크리스트

  • 모든 핵심 키워드 정리를 마쳤나요?
  • 핵심 키워드에 대해 완벽히 이해하셨나요?
  • 이론 학습 이후 직접 실습을 해보는 시간을 가졌나요?
  • 미션을 수행하셨나요?
  • 미션을 기록하셨나요?

✅ 컨벤션 체크리스트

  • 디렉토리 구조 컨벤션을 잘 지켰나요?
  • pr 제목을 컨벤션에 맞게 작성하였나요?
  • pr에 해당되는 이슈를 연결하였나요?(중요)
  • 적절한 라벨을 설정하였나요?
  • 파트장에게 code review를 요청하기 위해 reviewer를 등록하였나요?
  • 닉네임/main 브랜치의 최신 상태를 반영하고 있는지 확인했나요?(매우 중요!)

📌 주안점

미션 1은 3주차에 이미 진행한 내용으로 판단하여 별도로 업로드하지 않았습니다.

});

// accessToken 만료 시 재발급 인터셉터 등록
axiosInstance.interceptors.request.use((config) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 accessToken 만료 시 재발급을 안 해놓은 거 같은데 이렇게 재발급 요청도 따로 넣을 수 있군요! 참고하겠습니다! 코드가 깔끔해서 읽기 너무 좋아요!

@jjeunv jjeunv added the mission label Apr 11, 2026
Copy link
Copy Markdown
Collaborator

@qkrdmsthff qkrdmsthff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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("서버 오류가 발생했습니다. 잠시 후 다시 시도해주세요.");
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AccessToken 재발급 로직을 아주 잘 짜셨네요 카사!! 멋있습니다.

하지만, 현재 코드에서 여러 개의 API가 동시에 401 에러를 뱉는 경우,
페이지 로드 시 API 3개를 동시에 호출했는데 토큰이 만료되어 있었다면, refresh 함수가 3번 호출되고 localStorage 에 토큰이 꼬일 수 있습니다!

isRefreshing 플래그와 refreshSubscribers 큐를 만들어 첫 번째 요청만 refresh를 수행하고, 나머지 요청은 대기시켰다가 재발급 후 한꺼번에 실행해보는 방법을 적용해봐도 좋겠네요 ㅎㅎ 수고많으셨습니다

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants