fix: redirect to the actual login route on 401, not a nonexistent /login#226
Merged
Userunknown84 merged 1 commit intoJun 23, 2026
Conversation
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.
|
@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
approved these changes
Jun 23, 2026
Contributor
Author
|
@Userunknown84 Pls add the difficulty label to it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Axios response interceptor redirected users to
/loginafter a401 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 a401, redirect to/(the real login route) instead of/login. Token/user are still cleared fromlocalStoragefirst.Why
On session expiry the user should land on a usable login page, not a dead route.
Testing
401(e.g. expired token) and confirm the app clears auth state and routes to/showing the login screen.