Skip to content

Conversation

@Chiman2937
Copy link
Member

@Chiman2937 Chiman2937 commented Jan 1, 2026

📝 변경 사항

❓ 문제

Production 환경에 접속 후 login 성공 시 / 혹은 원래 path로 redirect되지 않고 /login 페이지에 머무는 현상

🔍 현재 구조

useLogin 훅에서 input 초기화, isAuthenticated를 true로 상태 변경, / 또는 원래 path로 redirect하는 로직 포함

      formApi.reset();

      setIsAuthenticated(true);

      const nextPath = normalizePath(searchParams.get('path'));
      window.location.replace(nextPath);

proxy.ts에서 accessToken 혹은 refreshToken이 없을 경우 /login으로 redirect(인증 필요한 페이지일 경우)

  // 둘 다 없으면 로그인 페이지로 redirect
  if (!accessToken && !refreshToken) {
    const loginUrl = new URL('/login', request.url);
    loginUrl.searchParams.set('error', 'unauthorized');
    loginUrl.searchParams.set('path', request.nextUrl.pathname);
    return NextResponse.redirect(loginUrl);
  }

💡 문제 원인에 대한 가설 정의 및 분석

No. 가설 분석 방법 분석 결과
1 router.replace 와 상태변경에 의한 리렌더링(formApi.reset(), setIsAuthenticated)의 타이밍 이슈를 추측 상태변경 로직 삭제 후 테스트 ❌ 관계없음
2 login 성공 후 redirect해야하는 페이지를 next 시스템이 prefetch를 해서 내부적으로 router.replace가 오동작할 것으로 추측 router.replace 전에 router.refresh 구문 추가 ❌ 관계없음
3 router.replace와 proxy.ts 실행 타이밍 충돌 추측 proxy.ts 제거 후 테스트 ✅ 정상동작
4 proxy.ts에서 accessToken 여부를 검사하는데, accessToken은 클라이언트에서 직접 set 하는 방식이기 때문에 proxy 실행 시점엔 accessToken을 인식 못할 것으로 추측 proxy.ts에서 refreshToken만 검사하도록 수정 ❌관계없음
5 router.refresh 자체의 결함으로 추측 router.push로 수정 ❌관계없음

proxy.ts와 router.replace의 타이밍 충돌인 것으로 확인

🔍 관련 문서

아래 글에서 현재 문제 상황과 동일한 내용을 발견 후 추가 테스트 검증
vercel/next.js#51782

No. 테스트 방법 결과
1 proxy.ts를 프로젝트 루트로 이동 후 검증 ❌ proxy.ts가 동작하지 않음(src 폴더 사용 시 반드시 src 폴더 내부 배치 필요)
2 proxy.ts를 middleware.ts 로 변경 ❌ 기존 동작에서 변화 없음
3 router.replace 대신 window.location.replace 사용 ✅ 정상 동작

✔️ 결론

proxy.ts를 제거할 수 없으므로 useLogin에서 router.replace 대신 window.location.replace를 사용해야합니다.


🔗 관련 이슈

Closes #


🧪 테스트 방법

  • 수동 테스트 검증(로컬 환경)
  • 유닛 테스트 검증
  • 통합 테스트 검증

📸 스크린샷 (선택)


📋 체크리스트

  • 관련 문서를 업데이트했습니다 (필요한 경우)
  • 테스트를 추가/수정했습니다 (필요한 경우)
  • Breaking change가 있다면 명시했습니다

💬 추가 코멘트


CodeRabbit Review는 자동으로 실행되지 않습니다.

Review를 실행하려면 comment에 아래와 같이 작성해주세요

@coderabbitai review

- proxy.ts: 인증 상태에서 /login, /signup 진입 시 /로 redirect하는 로직
  추가
- useLogin의 router.replace를 window.location.replace로 수정
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 1, 2026

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Jan 1, 2026

🎨 Storybook Report

변경 사항이 없습니다

모든 Story가 이전 빌드와 동일합니다.

Status Storybook Build Log Updated (UTC)
✅ Unchanged View Storybook View Build 2026-01-01 09:52:50

@github-actions
Copy link

github-actions bot commented Jan 1, 2026

🎭 Playwright Report

E2E Test가 성공적으로 완료되었습니다.

Test 요약 내용을 확인해주세요.

Status Build Log Updated (UTC)
✅ Ready View Build 2026-01-01 09:53:53

📊 Test Summary

  • ✅ Passed: 3
  • ❌ Failed: 0
  • ⏱️ Duration: 39.0s

📜 Test Details

✅ Passed Tests (3)
  • profile.test.ts (3)
    • [chromium] 존재하지 않는 프로필 페이지로 접속 시 404 redirect 되는 지 테스트
    • [firefox] 존재하지 않는 프로필 페이지로 접속 시 404 redirect 되는 지 테스트
    • [webkit] 존재하지 않는 프로필 페이지로 접속 시 404 redirect 되는 지 테스트

@github-actions
Copy link

github-actions bot commented Jan 1, 2026

📊 Coverage Report

Status Build Log Updated (UTC)
✅ Ready View Build 2026-01-01 09:52:31

📉 #307main에 병합하면 coverage가 0.02% 감소합니다.

Coverage 요약

@@             Coverage Diff             @@
##             main     #307       +/-   ##
===========================================
- Coverage   40.32%   40.30%    -0.02%     
===========================================
  Files         209      209         0     
  Lines        9384     9388        +4     
  Branches      406      406         0     
===========================================
  Hits         3784     3784         0     
+ Misses       5600     5604        +4     

영향받은 파일

파일 Coverage 변화
/home/runner/work/WeGo_FrontEnd/WeGo_FrontEnd/src/hooks/use-auth/use-auth-login/index.ts 21.56% (+0.21%) ⬆️

@github-actions
Copy link

github-actions bot commented Jan 1, 2026

🚀 PR Preview Report

Build가 성공적으로 완료되었습니다.

Preview에서 변경사항을 확인하세요.

Status Preview Build Log Updated (UTC)
✅ Ready Visit Preview View Logs 2026-01-01 09:53:35

@Chiman2937 Chiman2937 added the Ready For Review! 리뷰 받을 준비가 되었습니다. label Jan 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready For Review! 리뷰 받을 준비가 되었습니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants