Skip to content

배포 환경 로그아웃 시 쿠키 미삭제 및 페이지 이동 불가 수정#441

Merged
Bangdayeon merged 1 commit intomainfrom
fix/#439-logout-error
Mar 23, 2026
Merged

배포 환경 로그아웃 시 쿠키 미삭제 및 페이지 이동 불가 수정#441
Bangdayeon merged 1 commit intomainfrom
fix/#439-logout-error

Conversation

@Bangdayeon
Copy link
Copy Markdown
Member

관련 이슈

PR 설명

원인

  • 쿠키를 클라이언트(document.cookie)에서 설정했으나 클라이언트(useLogout.ts)에 쿠키 삭제 로직이 없어서 실패
  • 로컬에서는 middleware에서 dev일 경우 쿠키 검사를 건너뛰도록 하여 동작이 잘 됐던 것으로 추정

변경 사항

  • useLogout에서 로그아웃 성공/실패 시 클라이언트에서 직접 deleteCookieUtil로 쿠키 삭제하도록 수정

@Bangdayeon Bangdayeon self-assigned this Mar 22, 2026
@Bangdayeon Bangdayeon linked an issue Mar 22, 2026 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 22, 2026

Walkthrough

useLogout 훅이 홈 라우트로 네비게이션하기 전에 인증 관련 쿠키를 명시적으로 삭제하도록 수정되었습니다. clearCookies 헬퍼 함수를 통해 ACCESS_TOKEN, REFRESH_TOKEN, USER_INFO 쿠키가 삭제되며, 이 처리는 로그아웃 mutation의 성공/실패 여부와 관계없이 onSuccessonError 핸들러 모두에서 실행됩니다. 기존의 React Query 캐시 초기화에 더해 명시적인 쿠키 정리 로직이 추가되었습니다.

Possibly related PRs

  • 로그아웃 동작 수정 #388: 로그아웃 실패 시에도 인증 쿠키/토큰이 정리되도록 하는 로그아웃 흐름 개선 사항을 다루고 있어 관련성이 높습니다.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 주요 변경사항인 배포 환경 로그아웃 시 쿠키 미삭제 문제 수정을 명확하게 설명하고 있습니다.
Description check ✅ Passed PR 설명이 저장소의 필수 템플릿 구조를 따르고 있으며, 관련 이슈, 원인, 변경 사항을 구체적으로 기술하고 있습니다.
Linked Issues check ✅ Passed PR의 변경사항이 연결된 이슈 #439의 요구사항을 충족하고 있습니다. useLogout에서 로그아웃 시 쿠키 삭제 및 페이지 이동이 정상 동작하도록 수정되었습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 이슈 #439의 범위 내에 있으며, useLogout.ts의 쿠키 삭제 로직 추가만 포함되어 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/#439-logout-error

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.

Tip

CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.

Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/hooks/useLogout.ts (1)

20-29: 성공/실패 핸들러의 후처리 중복은 공통 함수로 합쳐두면 유지보수가 쉬워집니다.

현재 clearCookies → queryClient.clear → router.push('/')가 두 군데 중복되어 있어, 이후 변경 시 한쪽만 수정되는 리스크가 있습니다.

♻️ 제안 diff
   return useMutation({
     mutationFn: logout,
+    onSuccess: () => {
+      handleLogoutComplete();
+    },
+    onError: () => {
+      handleLogoutComplete();
+    },
+  });
+
+  function handleLogoutComplete() {
+    clearCookies();
+    queryClient.clear();
+    router.push('/');
+  }
-    onSuccess: () => {
-      clearCookies();
-      queryClient.clear();
-      router.push('/');
-    },
-    onError: () => {
-      clearCookies();
-      queryClient.clear();
-      router.push('/');
-    },
-  });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/hooks/useLogout.ts` around lines 20 - 29, Extract the duplicated cleanup
logic from the onSuccess and onError handlers into a single reusable function
(e.g., handleLogoutCleanup) and call that function from both onSuccess and
onError; specifically move clearCookies(), queryClient.clear(), and
router.push('/') into the new function and replace the inline sequences in the
existing onSuccess and onError handlers with a call to that function so future
changes are made in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/hooks/useLogout.ts`:
- Around line 20-29: Extract the duplicated cleanup logic from the onSuccess and
onError handlers into a single reusable function (e.g., handleLogoutCleanup) and
call that function from both onSuccess and onError; specifically move
clearCookies(), queryClient.clear(), and router.push('/') into the new function
and replace the inline sequences in the existing onSuccess and onError handlers
with a call to that function so future changes are made in one place.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 323ab0e3-1c4c-4d52-9842-fca39e2e234b

📥 Commits

Reviewing files that changed from the base of the PR and between b6eff47 and fc4c299.

📒 Files selected for processing (1)
  • src/hooks/useLogout.ts

@Bangdayeon Bangdayeon merged commit eda67c6 into main Mar 23, 2026
3 checks passed
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.

로그아웃 버튼 동작 안됨

2 participants