Skip to content

fix: redirect to the actual login route on 401, not a nonexistent /login#226

Merged
Userunknown84 merged 1 commit into
Userunknown84:mainfrom
Rudra-clrscr:fix/axios-401-redirect-missing-route
Jun 23, 2026
Merged

fix: redirect to the actual login route on 401, not a nonexistent /login#226
Userunknown84 merged 1 commit into
Userunknown84:mainfrom
Rudra-clrscr:fix/axios-401-redirect-missing-route

Conversation

@Rudra-clrscr

Copy link
Copy Markdown
Contributor

Summary

The Axios response interceptor redirected users to /login after a 401 Unauthorized, but no such route exists in the app — the login page lives at /. As a result an expired/invalid token left users on a blank/not-found page instead of the login screen.

Change

  • frontend/src/utils/axiosInstance.js: on a 401, redirect to / (the real login route) instead of /login. Token/user are still cleared from localStorage first.

Why

On session expiry the user should land on a usable login page, not a dead route.

Testing

  • Trigger a 401 (e.g. expired token) and confirm the app clears auth state and routes to / showing the login screen.

axiosInstance's response interceptor cleared the session and redirected
to /login on any 401, but the router only defines /, /register, /app and
/dashboard - / renders the Login page. Hitting /login landed on a blank
page with no way back in, since there's no matching route or catch-all.

Found while testing an unrelated change: an expired/invalid token on
/dashboard blanked the screen instead of bouncing back to login.
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

@Rudra-clrscr is attempting to deploy a commit to the Aditya Sharma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Userunknown84 Userunknown84 merged commit b099b0f into Userunknown84:main Jun 23, 2026
4 of 6 checks passed
@Rudra-clrscr

Copy link
Copy Markdown
Contributor Author

@Userunknown84 Pls add the difficulty label to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants