. - #28
Merged
Merged
.#28
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 PR Description
API 401 응답 시 발생하던
/login리다이렉트 로직의 구조적 결함을 해결하고, SPA 구조에 적합한 라우팅 방식과 React Query 싱글톤 패턴을 도입했습니다. 특히 인터셉터 내 하드 리로드 문제를 해결하여 사용자 경험을 개선했습니다.🔧 Changes
1. API 인스턴스 401 처리 로직 수정 (
src/api/instance.ts)isRefreshRequest,alreadyRetried분기 및newAccessToken부재 시 리다이렉트가 누락되던 현상 해결router.navigate를 일괄 처리하는redirectToLogin()헬퍼 함수 도입console.log제거 및 에러 흐름 정형화2. 라우팅 구조 고도화 (
window.location.href→router.navigate())BrowserRouter방식에서createBrowserRouter및RouterProvider기반으로 마이그레이션src/router.tsx신규 생성)3. QueryClient 싱글톤 적용
FullWidthLayout등)에서 개별 생성하던QueryClient를src/api/queryClient.ts의 싱글톤 인스턴스로 통합retry,staleTime정책 적용 및 캐시 분리 문제 해결4. 인증 기반 라우트 보호 (
ProtectedRoute)/,/searchpage,/writepage등 주요 경로에ProtectedRoute적용accessToken부재 시 진입 단계에서 즉시 리다이렉트 처리📌 Summary
이번 작업을 통해 인증 실패 시의 예외 처리를 완벽하게 보완하고, 전역 상태(Query, Router)의 일관성을 확보했습니다.
QueryClient설정 및 라우트 관리