Conversation
WalkthroughAuthGuard 컴포넌트를 제거하고 Suspense/SentryRoutes 래핑 구조를 재정렬했습니다. 인증 상태 관리를 boolean의 isAuthenticated에서 AuthStatus 문자열 타입( Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/components/auth/PublicRoute.tsx (1)
5-11:⚠️ Potential issue | 🟡 Minor
unknown상태도 막아주세요.지금은 세션 복구 중인
unknown상태에서도 바로<Outlet />을 열어서, 로그인된 사용자가 새로고침하면 로그인/회원가입 화면이 잠깐 보였다가/home으로 이동하는 플래시가 생깁니다.ProtectedRoute처럼 여기서도 로딩 fallback을 먼저 보여주는 쪽이 안전합니다.제안
function PublicRoute() { const authStatus = useAuthStore((state) => state.authStatus); + if (authStatus === 'unknown') { + return <RouteLoadingFallback fullScreen />; + } + if (authStatus === 'authenticated') { return <Navigate to="/home" replace />; } return <Outlet />; }상단에
RouteLoadingFallbackimport도 하나 추가해주세요.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/auth/PublicRoute.tsx` around lines 5 - 11, PublicRoute currently renders <Outlet /> during the 'unknown' authStatus which causes a flash; update the component so that when useAuthStore((s)=>s.authStatus) === 'unknown' it returns <RouteLoadingFallback /> (add an import for RouteLoadingFallback at the top), otherwise keep the existing checks (if 'authenticated' return <Navigate to="/home" replace />; else return <Outlet />). Ensure you reference useAuthStore and authStatus inside PublicRoute and add the RouteLoadingFallback import.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main.tsx`:
- Around line 22-24: The current bootstrap only calls startSessionRestore() if
window.location.pathname !== SERVER_ERROR_PATH at load, so entering or
refreshing on /server-error permanently skips session restoration and leaves
authStatus as unknown; change this to guarantee restoration once the app
navigates off /server-error by adding a one-time route watcher (e.g., a
history/location listener or a useEffect tied to the router) that calls
startSessionRestore() (or initialize() completion) the first time pathname !==
SERVER_ERROR_PATH after startup; ensure the watcher cleans itself up after
invoking startSessionRestore() so it only runs once and that ProtectedRoute and
useErrorPageHomeNavigation see a resolved authStatus.
---
Outside diff comments:
In `@src/components/auth/PublicRoute.tsx`:
- Around line 5-11: PublicRoute currently renders <Outlet /> during the
'unknown' authStatus which causes a flash; update the component so that when
useAuthStore((s)=>s.authStatus) === 'unknown' it returns <RouteLoadingFallback
/> (add an import for RouteLoadingFallback at the top), otherwise keep the
existing checks (if 'authenticated' return <Navigate to="/home" replace />; else
return <Outlet />). Ensure you reference useAuthStore and authStatus inside
PublicRoute and add the RouteLoadingFallback import.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4685a4f7-ab6c-40ee-9e71-243c9c28ac54
📒 Files selected for processing (7)
src/App.tsxsrc/components/auth/AuthGuard.tsxsrc/components/auth/ProtectedRoute.tsxsrc/components/auth/PublicRoute.tsxsrc/main.tsxsrc/stores/authStore.tssrc/utils/hooks/useErrorPageHomeNavigation.ts
💤 Files with no reviewable changes (1)
- src/components/auth/AuthGuard.tsx
| if (window.location.pathname !== SERVER_ERROR_PATH) { | ||
| startSessionRestore(); | ||
| } |
There was a problem hiding this comment.
/server-error에서 시작하면 세션 복구가 아예 시작되지 않습니다.
Line 22 분기는 부트스트랩 시점에 한 번만 평가됩니다. 그래서 사용자가 /server-error로 직접 진입하거나 그 페이지에서 새로고침하면 initialize()가 끝까지 호출되지 않고, 이후 SPA 내비게이션으로 다른 라우트로 이동해도 authStatus가 계속 unknown에 머뭅니다. 그 상태에서는 ProtectedRoute가 로딩에 갇히고, useErrorPageHomeNavigation도 항상 /로 보내게 됩니다. 초기 URL만 기준으로 스킵하지 말고, 적어도 /server-error를 벗어나는 첫 시점에는 세션 복구가 보장되게 해주세요.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/main.tsx` around lines 22 - 24, The current bootstrap only calls
startSessionRestore() if window.location.pathname !== SERVER_ERROR_PATH at load,
so entering or refreshing on /server-error permanently skips session restoration
and leaves authStatus as unknown; change this to guarantee restoration once the
app navigates off /server-error by adding a one-time route watcher (e.g., a
history/location listener or a useEffect tied to the router) that calls
startSessionRestore() (or initialize() completion) the first time pathname !==
SERVER_ERROR_PATH after startup; ensure the watcher cleans itself up after
invoking startSessionRestore() so it only runs once and that ProtectedRoute and
useErrorPageHomeNavigation see a resolved authStatus.
Summary by CodeRabbit
릴리스 노트