Implemented global 401 response handling to properly redirect users to login when their session expires: Changes: frontend/src/api/client.ts: Added setAuthErrorHandler() callback pattern and enhanced 401 interceptor to notify auth context frontend/src/context/AuthContext.tsx: Register auth error handler that clears state and redirects to /login on 401 responses tests/core/authentication.spec.ts: Fixed test to clear correct localStorage key (charon_auth_token) The implementation uses a callback pattern to avoid circular dependencies while keeping auth state management centralized. Auth endpoints (/auth/login, /auth/me) are excluded from the redirect to prevent loops during initial auth checks. All 16 authentication E2E tests now pass including: should redirect to login when session expires should handle 401 response gracefully Closes frontend-auth-guard-reload.md
258 KiB
258 KiB