Skip to content

fix: preserve session on server cold starts and auto-redirect authenticated users to dashboard#69

Merged
Atanu2k4 merged 2 commits into
sanks011:masterfrom
Atanu2k4:master
Jun 6, 2026
Merged

fix: preserve session on server cold starts and auto-redirect authenticated users to dashboard#69
Atanu2k4 merged 2 commits into
sanks011:masterfrom
Atanu2k4:master

Conversation

@Atanu2k4

@Atanu2k4 Atanu2k4 commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes an issue where users were unexpectedly logged out when the server experienced a restart or cold start. It also ensures that authenticated users arriving at the root landing page (/) are automatically redirected to their dashboard rather than being prompted to log in again.

Related issue

Fixes #68

Changes

  • AuthContext.tsx: Restricted session clearing to definitive 401 or 404 responses. Network issues and transient server errors (500 range) will now gracefully fall back to the cached user session instead of wiping localStorage.
  • page.tsx: Added validation checks for the active user state on the landing page, automatically replacing the route with /dashboard if an active session is detected.

Testing

  • Redirection verification: Navigated directly to the root domain (/) with a valid token in localStorage and verified immediate redirection to /dashboard.
  • Cold start resiliency testing: Simulated a failed/slow API endpoint and confirmed that network failures no longer destroy the local credentials cache.

Checklist

  • Title follows the repository PR format
  • The issue is linked with Fixes #68
  • Testing notes are included

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

PR Validation Passed

Your PR title and description meet all requirements:

@Atanu2k4 Atanu2k4 merged commit d1d57fc into sanks011:master Jun 6, 2026
1 of 3 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.

Fix: Session logout on server cold-starts & missing auto-redirect on home page

1 participant