feat: 5주차 두번째 미션 - #52
Open
kimdoyeon1234 wants to merge 32 commits into
Open
Conversation
1주차 미션1 - 뮤
Feat: 2주차 미션1 - 뮤
Feat: 2주차 미션2 - 뮤
Feat: Week3/nonshaman m2
Revert "Feat: Week3/nonshaman m2"
yewon20804
reviewed
May 5, 2026
yewon20804
left a comment
Collaborator
There was a problem hiding this comment.
5주차 미션 2도 확인했습니다
로그인할 때 refreshToken을 저장하지 않고있습니다
// 현재 코드
if (response.data.status) {
localStorage.setItem('accessToken', response.data.data.accessToken);
alert(`${response.data.data.name}님 환영합니다!`);
navigate('/mypage');
}
apis/axios.ts에 401 오류 발생 시 refreshToken으로 accessToken을 재발급하는 로직을 만들어주셨는데, 로그인할 때 refreshToken 자체를 저장하지 않으면 재발급 로직이 동작하지 않습니다!
localStorage.setItem('refreshToken', refreshToken);
이 줄을 추가해주시면 좋을 것 같습니다 !
MyPage.tsx에서 헤더를 수동으로 중복해서 붙이고 있습니다 !
현재 코드를 이렇게 작성해주셨는데
const response = await api.get('/users/me', {
headers: {
Authorization: Bearer ${token}
}
});
apis/axios.ts에 api를 통한 모든 요청에 자동으로 Authorization 헤더가 붙도록 처리해주셨습니다!
그래서 헤더를 붙이지 않고 바로 호출해주셔도 가능합니다 !
api.interceptors.request.use((config) => {
const token = localStorage.getItem('accessToken');
if (token && config.headers) {
config.headers.Authorization = `Bearer ${token}`; // 여기서 자동으로 붙여줌!
}
return config;
});
로그아웃할 때 refreshToken은 삭제하고 있지 않고 있습니다
const handleLogout = () => {
localStorage.removeItem('accessToken'); // accessToken만 지움
alert('로그아웃 되었습니다.');
navigate('/login', { replace: true });
};
로그아웃을 하면 두 토큰 모두 localStorage에서 지워야 합니다!
localStorage.removeItem('refreshToken');
이 줄도 추가해주시면 좋을것 같아요
작성해드린 코멘트 확인 부탁드립니다 ㅎㅎ 👍
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.
📚 주차 / 미션
📌 작업 내용
✨ 상세 작업 내용
📸 스크린샷
❓ 리뷰어가 알아야 할 사항 / 질문
✅ 체크리스트