Skip to content

[FE] 만료 토큰의 400 응답도 세션 만료로 처리 (#509) - #411

Merged
sumi-0011 merged 1 commit into
devfrom
fix/backend-auth-fail-400
Sep 4, 2026
Merged

sumi-0011 merged 1 commit into
devfrom
fix/backend-auth-fail-400

Conversation

@sumi-0011

Copy link
Copy Markdown
Member

💻 작업 내용

토큰이 만료되면 세션 만료 다이얼로그가 뜨지 않고 일반 에러로 새던 문제를 고칩니다. 인터셉터가 401만 세션 만료로 봤는데, 백엔드는 만료 토큰에 400을 줍니다. gitanimals#509 의 남은 절반입니다.

실측 (api.gitanimals.org, 2026-09-04):

요청 응답
Authorization 헤더 없음 401 {"message":"Required request header 'Authorization' ... is not present"}
만료·무효 토큰 400 {"message":"Authorization fail"}

이슈에 첨부된 콘솔의 api.gitanimals.org/inboxes → 400이 정확히 두 번째 경우입니다.

주요 변경

  • isAuthFailureResponse 로 401과 400 Authorization fail 을 함께 인증 실패로 판정합니다
  • 메시지까지 보므로 평범한 400(invalid personaId 등)은 그대로 통과합니다 — 엉뚱한 요청 실패에 세션 만료 다이얼로그가 뜨지 않습니다
  • 판정 함수는 sessionExpired.ts 에 뒀습니다. interceptor.ts 는 모듈 최상위에서 react 의 cache() 를 호출해 node 테스트 환경에서 import 자체가 안 됩니다

📸 스크린샷

동작 변화는 다이얼로그 노출 여부뿐이라 UI 변경 없음.

인터셉터가 401 만 세션 만료로 봤는데, 백엔드는 만료·무효 토큰에 400 을 준다.
정작 진짜 만료 케이스에서 다이얼로그가 안 뜨고 일반 에러로 새고 있었다.

api.gitanimals.org 실측 (2026-09-04):
  Authorization 헤더 없음 → 401 "Required request header 'Authorization' ... is not present"
  만료·무효 토큰          → 400 "Authorization fail"

- isAuthFailureResponse 로 401 과 400 "Authorization fail" 을 함께 인증 실패로 본다
- 메시지까지 보므로 평범한 400 은 그대로 통과한다
- 판정 함수는 sessionExpired.ts 에 둔다. interceptor.ts 는 모듈 최상위에서
  react 의 cache() 를 호출해 node 테스트 환경에서 import 가 안 된다

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BMdPChPLYGeqjok2W3kbCA
@sumi-0011
sumi-0011 requested a review from hyesungoh as a code owner September 4, 2026 01:26
@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: c5c0c41d-93d0-46d5-8b3a-1f173f5c9403

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@sumi-0011
sumi-0011 merged commit ab95f83 into dev Sep 4, 2026
5 checks passed
@sumi-0011
sumi-0011 deleted the fix/backend-auth-fail-400 branch September 4, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant