Skip to content

Conversation

@Chuseok22
Copy link
Member

@Chuseok22 Chuseok22 commented Sep 16, 2025

Summary by CodeRabbit

  • 신기능

    • 사이드바 하단에 로그아웃 버튼을 추가했습니다.
    • 로그아웃 진행 중 상태(비활성화 및 “로그아웃 중...” 표시)를 제공합니다.
    • 클릭 시 안전하게 로그아웃 처리 후 토큰을 삭제하고 로그인 페이지로 이동합니다.
  • 리팩터링

    • 환경 설정을 정리해 로그인/로그아웃 요청 경로를 일관되게 관리하여 안정성을 향상했습니다.

@coderabbitai
Copy link

coderabbitai bot commented Sep 16, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

새 로그아웃 플로우를 추가하고 로그인 라우트에서 API_BASE_URL 주입 방식을 정적 import로 변경했다. 공용 상수 모듈을 신설했다. 사이드바 UI는 푸터에 전용 로그아웃 버튼을 도입하고 토큰 제거 및 로그인 페이지로 리다이렉트하도록 처리했다.

Changes

Cohort / File(s) Summary
Logout API (client + route)
src/app/(with-layout)/_shared/services/logout-api.ts, src/app/api/logout/route.ts
새 로그아웃 클라이언트 함수 logout() 추가(POST /api/logout 호출). 서버 측에 POST 핸들러 추가하여 ${API_BASE_URL}/api/admin/logout로 포워딩하고 오류 시 CustomError(ErrorCode.INVALID_REQUEST) 발생.
Sidebar UI integration
src/components/common/app-sidebar.tsx
사이드바에 푸터 로그아웃 버튼 추가. 클릭 시 로딩 상태, 토큰(localStorage) 제거, logout() 호출 후 router.replace('/login'). 기존 메뉴 항목의 로그아웃 제거.
API base URL centralization
src/lib/api/types.ts, src/app/api/login/route.ts
API_BASE_URL 상수 모듈 신설(process.env.API_BASE_URL). 로그인 라우트가 기존 환경변수 직접 참조 대신 API_BASE_URL를 정적 import로 사용.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor U as User
    participant S as AppSidebar (Client)
    participant C as /api/logout (Next Route)
    participant B as Backend API (/api/admin/logout)

    U->>S: Click "로그아웃"
    note right of S: setLoading(true)<br/>localStorage remove tokens
    S->>C: POST /api/logout
    C->>B: POST /api/admin/logout (API_BASE_URL)
    B-->>C: 200/4xx Response
    alt success
        C-->>S: 200 OK
        S->>S: setLoading(false)
        S->>S: router.replace('/login')
    else error
        C-->>S: Error (throws)
        S->>S: setLoading(false)
        note right of S: stays on page or handle error
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Poem

밤하늘 탭을 살금살금 닫고,

토큰은 뽀득뽀득 씻어 바람에 놓고,

버튼 한 번, hoppity-hop 로그아웃! 🐇✨

새벽 로그인 길로 살짝 점프—

깔끔한 발자국만 남겨두고 간다.

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 20250916_#6_기능추가_인증_Nextjs_로그아웃_연동

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 250eeca and d2e43cd.

📒 Files selected for processing (5)
  • src/app/(with-layout)/_shared/services/logout-api.ts (1 hunks)
  • src/app/api/login/route.ts (1 hunks)
  • src/app/api/logout/route.ts (1 hunks)
  • src/components/common/app-sidebar.tsx (4 hunks)
  • src/lib/api/types.ts (1 hunks)

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.

@Chuseok22 Chuseok22 linked an issue Sep 16, 2025 that may be closed by this pull request
@Chuseok22 Chuseok22 merged commit 2b73399 into main Sep 16, 2025
1 of 2 checks passed
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.

⚙️ [기능추가][인증] Next.js 로그아웃 연동

2 participants