Skip to content

[5주차/조이] 워크북 제출합니다.#54

Open
aeongiing wants to merge 6 commits intoUMC-Inha:조이/mainfrom
aeongiing:main
Open

[5주차/조이] 워크북 제출합니다.#54
aeongiing wants to merge 6 commits intoUMC-Inha:조이/mainfrom
aeongiing:main

Conversation

@aeongiing
Copy link
Copy Markdown
Member

@aeongiing aeongiing commented Apr 29, 2026

✅ 워크북 체크리스트

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

✅ 컨벤션 체크리스트

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

📌 주안점

@aeongiing aeongiing self-assigned this Apr 29, 2026
@aeongiing aeongiing requested a review from qkrdmsthff as a code owner April 29, 2026 14:51
@aeongiing
Copy link
Copy Markdown
Member Author

시험이 오늘 끝나서 미션은 내일 스터디 전까지 꼭 다 끝내서 제출하겠습니다..! 죄송합니다 ㅠㅠ

Comment thread mission/chapter05/mission03/src/apis/axiosInstance.ts Outdated
Comment thread mission/chapter05/mission02/src/apis/axiosInstance.ts Outdated
Comment thread mission/chapter05/mission01/src/hooks/useCustomFetch.ts
- useCustomFetch: useRef로 fetchFn 참조 관리, 의존성 배열을 []로 변경
  → useCallback 누락 시 발생하는 무한 재렌더 방지
- axiosInstance(mission02, 03): refreshPromise 모듈 스코프 공유
  → Refresh Token Rotation 환경에서 동시 401 시 중복 갱신 호출 방지
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 조이 수고하셨습니다!! 이번주도 화이팅

import axios from 'axios';
import type { MovieResponse, MovieDetail, Credits } from '../types/movie';

const BASE_URL = 'https://api.themoviedb.org/3';
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.

baseURL 을 하드코딩 하는 것보다 .env 파일에 넣어서 관리하는 것이배포 환경이 바뀔 때에 따라 유연하게 대처할 수 있어요!

} catch {
localStorage.removeItem('accessToken');
localStorage.removeItem('refreshToken');
window.location.href = '/login';
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.

현재 SPA 의 장점을 무시하고 window.location.href 를 사용해서 페이지를 이동하고 있습니다! react-route-dom 의 useNavigate 훅을 사용해 보는 것을 권장합니다!

localStorage.removeItem('accessToken');
localStorage.removeItem('refreshToken');
window.location.href = '/login';
return Promise.reject(error);
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.

return Promise.reject(error) 를 할 때,
리프레시 실패 원인을 넘길지 원래의 401 에러(error)를 넘길지 결정하면 좋습니당!! 보통은 인증 실패임을 알리기 위해 원래 에러를 넘기는 지금 방식도 괜찮은 거 같습니다 ㅎㅎ

try {
if (!refreshPromise) {
const stored = localStorage.getItem('refreshToken');
const refreshToken = stored ? (JSON.parse(stored) as string) : null;
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.

현재 localStorage 에서 값을 읽어올 때 JSON.parse 를 사용하고 있는데, 이 부분에서 두 가지 개선 방향을 제안드립니다!

안정성 확보 : 사용자가 브라우저 콘솔에서 값을 조작하거나 데이터가 오염되었을 경우 JSON.parse 에서 런타임 에러가 발생해 앱이 멈출 수 있습니다! 이를 방지하기 위해 try-catch 로 감싸는 것을 추천합니다!

저장 방식 단순화 : 토큰은 객체가 아닌 단순 문자열인 경우가 많습니다. JSON.stringify 없이 순수 문자열로 저장하고 getItem 으로 바로 읽어오면 따옴표 처리나 파싱 에러 걱정 없이 더 간결하게 관리할 수 있습니다!

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.

Chapter05_리프레시 토큰 기반의 안전한 접근 제어 전략과 소셜 로그인

5 participants