Skip to content

[fix] 어드민 로그인 시 localhost:3001로 이동되는 문제 수정#419

Merged
yeondon125 merged 1 commit into
developfrom
fix/admin-login-redirect
Jun 19, 2026
Merged

[fix] 어드민 로그인 시 localhost:3001로 이동되는 문제 수정#419
yeondon125 merged 1 commit into
developfrom
fix/admin-login-redirect

Conversation

@yeondon125

@yeondon125 yeondon125 commented Jun 19, 2026

Copy link
Copy Markdown
Member

개요 💡

스테이지 어드민(admin.stage.hellogsm.kr)에서 로그인하면 콜백 처리 후 http://localhost:3001/로 이동하던 버그(#418)를 수정합니다.

원인은 #411에서 어드민 도메인 판별을 환경변수 기반 → 서버 Host 헤더(headers().get('host')) 기반으로 바꾼 데 있습니다. 스테이지는 리버스 프록시를 통해 내부 호스트(localhost)를 Host로 전달하므로, host.includes('localhost')가 먼저 매칭돼 항상 localhost:3001로 리다이렉트됩니다.

작업내용 ⌨️

  • apps/client/src/app/AdminRedirect.tsx 신규 추가
    • 브라우저 주소창 값인 window.location.origin 기준으로 어드민 URL을 판별해 리다이렉트하는 클라이언트 컴포넌트
    • localhost → localhost:3001, stage → admin.stage.hellogsm.kr, 운영 → admin.hellogsm.kr
  • apps/client/src/app/page.tsx
    • 서버 Host 헤더 기반 판별 블록 제거 → <AdminRedirect /> 렌더로 교체
    • 미사용 headers import 제거 (redirect/signup 분기에서 계속 사용)
    • 서버 측 권한 검증(isAdminRequested && isAdminRole)은 그대로 유지

왜 이 방식인가

window.location.origin은 브라우저 주소창 값이라 리버스 프록시의 영향을 받지 않습니다. 또한 이 신호는 이미 동일 플로우의 LoginButton(redirectUri 생성)과 CallbackPage(/?isAdmin=true 생성)에서 정상 동작 중이므로, 검증된 신호를 마지막 리다이렉트에도 그대로 사용하는 변경입니다.

관련 이슈 🚨

리뷰 요청사항 👀

  • 로컬에서는 정상 동작을 확인했으나, 실제 스테이지 프록시 환경은 배포 후에야 최종 검증이 가능합니다. 스테이지 배포 시 admin.stage.hellogsm.kr/signin 로그인 → 콜백 후 admin.stage.hellogsm.kr로 복귀하는지 확인 부탁드립니다.

서버 Host 헤더(`headers().get('host')`)로 어드민 도메인을 판별하던 로직이
스테이지 리버스 프록시 환경에서 내부 호스트(localhost)를 받아 항상
localhost:3001로 리다이렉트되던 문제를 수정한다.

판별 기준을 브라우저 주소창 값인 window.location.origin으로 옮긴 클라이언트
컴포넌트 AdminRedirect로 교체했다. 서버 측 권한 검증(isAdminRole)은 그대로
유지된다.

resolves #418

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hellogsm-client-26 Ready Ready Preview, Comment Jun 19, 2026 1:37am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hellogsm-client-26-admin Skipped Skipped Jun 19, 2026 1:37am

Request Review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request replaces the server-side redirection logic in page.tsx with a new client-side redirection component, AdminRedirect.tsx. The review feedback suggests reverting to server-side redirection by utilizing the X-Forwarded-Host header to prevent a flash of the loading state and improve user experience. Additionally, it is recommended to remove unnecessary cn utility calls for static Tailwind CSS classes in the new component.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread apps/client/src/app/page.tsx
Comment thread apps/client/src/app/AdminRedirect.tsx
@s2yeons s2yeons changed the title fix: 어드민 로그인 시 localhost:3001로 이동되는 문제 수정 [fix] 어드민 로그인 시 localhost:3001로 이동되는 문제 수정 Jun 19, 2026

@junjuny0227 junjuny0227 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

코드상으로는 큰 문제 없어 보이긴 하는데, 실제로 적용해봐야 정확히 확인할 수 있을 것 같습니다. 한 분 더 승인받은 뒤에 머지하시죠

@s2yeons s2yeons left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

수고하셨습니다

@yeondon125 yeondon125 merged commit c33bf17 into develop Jun 19, 2026
4 checks passed
@yeondon125 yeondon125 deleted the fix/admin-login-redirect branch June 19, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants