Skip to content

Fix: Resolve session restoration failure by correcting AuthContext API endpoint#1481

Open
Abhishek2005-ard wants to merge 27 commits into
aryandas2911:mainfrom
Abhishek2005-ard:fix/authcontext-session-restore
Open

Fix: Resolve session restoration failure by correcting AuthContext API endpoint#1481
Abhishek2005-ard wants to merge 27 commits into
aryandas2911:mainfrom
Abhishek2005-ard:fix/authcontext-session-restore

Conversation

@Abhishek2005-ard

@Abhishek2005-ard Abhishek2005-ard commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes a bug where the frontend application silently failed to restore a user's session on page refresh, causing authenticated users to be treated as logged-out.

The useEffect hook in frontend/src/context/AuthContext.jsx was attempting to fetch user data on load using the GET /auth/me endpoint. However, the backend router only defines GET /auth/user. This resulted in a 404 error, triggering the catch block and clearing the user session state.

Updating the endpoint to the correct route resolves this, allowing the session to persist securely across page reloads.

Changes Made

  • Updated the API fetch call in frontend/src/context/AuthContext.jsx from /auth/me to /auth/user.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

close #1478

@Abhishek2005-ard

Copy link
Copy Markdown
Contributor Author

@aryandas2911
pls review this pr

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.

Bug: Session restoration fails on refresh due to incorrect /auth/me endpoint in AuthContext

1 participant