Skip to content

Commit

Permalink
Merge pull request #315 from oduck-team/fix/314
Browse files Browse the repository at this point in the history
fix: 프로덕션 환경에서 프로필 페이지 새로고침 오류 테스트
  • Loading branch information
presentKey authored Nov 26, 2023
2 parents 3be3cdf + 87ef539 commit 01741ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/features/auth/contexts/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ export function AuthProvider({ children }: PropsWithChildren) {

const fetchUser = useCallback(async () => {
try {
console.log("AuthProvider fetchUser try");
const user = await authApi.getStatus();
console.log(user);
setUser(user);
setAutoLogin(true);
console.log("AuthProvider fetchUser try end");
} catch (e) {
console.log("AuthProvider fetchUser 오류 발생");

setUser(undefined);
//FIXME: 배포환경 테스트를 위해 주석 처리
// removeAutoLogin();
Expand Down
4 changes: 4 additions & 0 deletions src/routes/privateRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ function PrivateRoute({ children }: PropsWithChildren) {
* 유저 정보가 없다면 로그인 페이지로 이동합니다.
*/
useEffect(() => {
console.log("PrivateRoute user 정보");
console.log(user);

if (!user) {
console.log("PrivateRoute: 로그인 페이지로 이동");
navigate("/login", { replace: true });
}
}, [navigate, user]);
Expand Down

0 comments on commit 01741ed

Please sign in to comment.