Skip to content

fix(auth): 로그인 후 콜백 URL 절대경로 처리 수정 - #114

Merged
evenif99 merged 1 commit into
devfrom
fix/auth-callback-url
Jun 22, 2026
Merged

fix(auth): 로그인 후 콜백 URL 절대경로 처리 수정#114
evenif99 merged 1 commit into
devfrom
fix/auth-callback-url

Conversation

@evenif99

@evenif99 evenif99 commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • 미들웨어가 callbackUrl을 절대 URL(https://...)로 생성하지만, login/callback 페이지에서 상대 경로만 허용하여 로그인 성공 후 원래 페이지 대신 홈(/)으로 리다이렉트되는 버그 수정
  • login/page.tsx: 절대 URL → 상대 경로 변환 후 전달
  • auth/callback/page.tsx: new URL() 파싱으로 pathname 추출하여 리다이렉트

Test plan

  • 비회원 상태에서 감정일기(/diary) 클릭 → 로그인 → 로그인 후 /diary로 복귀 확인
  • 비회원 상태에서 마이페이지(/mypage) 클릭 → 로그인 → 로그인 후 /mypage로 복귀 확인
  • 직접 /login 접속 → 로그인 → 홈(/)으로 이동 확인
  • 잘못된 callbackUrl 전달 시 홈으로 안전하게 리다이렉트 확인

🤖 Generated with Claude Code

Summary by CodeRabbit

릴리스 노트

  • Bug Fixes
    • 인증 및 로그인 콜백 리다이렉트 경로 검증 로직 개선
    • 리다이렉트 경로 처리의 안정성 및 보안성 강화

미들웨어가 callbackUrl을 절대 URL(https://...)로 생성하지만
login, auth/callback 페이지에서 상대 경로만 허용해 로그인 성공 후
원래 페이지 대신 홈(/)으로 리다이렉트되는 문제 수정.

- login: 절대 URL을 상대 경로로 변환 후 전달
- auth/callback: URL 파싱으로 pathname 추출하여 리다이렉트

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

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
talky-owl Ignored Ignored Jun 22, 2026 10:15am

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 5c799c2e-1c98-4351-89e3-b3bce43dfd7e

📥 Commits

Reviewing files that changed from the base of the PR and between 72a7d57 and 7def718.

📒 Files selected for processing (2)
  • src/app/(page)/auth/callback/page.tsx
  • src/app/(page)/login/page.tsx

📝 Walkthrough

Walkthrough

auth/callback 페이지에서 callbackUrl 유효성 검사 방식을 문자열 접두 조건에서 URL 파싱 후 pathname 추출로 변경하고, login 페이지에 toRelativePath 유틸리티를 추가해 callbackUrl 파라미터를 상대 경로로 안전하게 변환합니다.

Changes

callbackUrl 파싱 로직 URL 기반으로 개선

Layer / File(s) Summary
toRelativePath 유틸리티 및 returnTo 계산
src/app/(page)/login/page.tsx
toRelativePath(url) 함수를 추가해 입력 URL을 파싱한 뒤 pathname + search + hash 형태로 반환하고, 파싱 실패 시 /를 반환. callbackUrl 파라미터에 이를 적용해 returnTo를 계산하도록 변경.
auth/callback URL 파싱 기반 callbackUrl 결정
src/app/(page)/auth/callback/page.tsx
callbackUrl'/'로 초기화한 뒤, new URL(raw, window.location.origin).pathname으로 파싱해 pathname을 적용. /auth/callback 이동 및 // 시작 값 제외, 파싱 실패 시 try/catch로 기본값 유지.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • I5-Project/TALKY-OWL#61: auth/callback/page.tsxlogin/page.tsx에서 callbackUrl 처리 로직을 동일하게 수정한 PR로, 직접적으로 겹치는 코드 영역을 다룸.
  • I5-Project/TALKY-OWL#63: auth/callback/page.tsx에서 인증 시 callbackUrl 쿼리 파라미터의 유효성 처리를 다루는 동일 코드 영역을 수정한 PR.

Suggested reviewers

  • lyla-bae
  • wjdalss21

Poem

🐇 URL을 파싱해 안전한 길을 찾아요
문자열 검사는 이제 안녕~ 👋
pathname만 쏙 뽑아내는 토끼,
try/catch로 실수도 살포시 감싸고
/로 돌아오는 따뜻한 기본값~ 🏠

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/auth-callback-url

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

@evenif99
evenif99 merged commit 3ac101e into dev Jun 22, 2026
2 of 3 checks passed
@evenif99
evenif99 deleted the fix/auth-callback-url branch June 25, 2026 04:12
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.

1 participant