Skip to content

fix: prevent sending string 'null' or 'undefined' tokens to backend (Issue #257)#305

Closed
basantnema31 wants to merge 1 commit into
hereisSwapnil:mainfrom
basantnema31:fix/null-token
Closed

fix: prevent sending string 'null' or 'undefined' tokens to backend (Issue #257)#305
basantnema31 wants to merge 1 commit into
hereisSwapnil:mainfrom
basantnema31:fix/null-token

Conversation

@basantnema31

Copy link
Copy Markdown

Fixes #257

The Bug:
Whenever localStorage gets corrupted or improperly set, getItem("token") can return the literal strings "null" or "undefined". The truthiness check if (!token) evaluates these strings as true, causing the frontend to send a request to the backend with Authorization: Bearer null. The backend crashes when trying to parse this invalid token data, preventing the frontend page from rendering.

The Fix:
Updated UserContext.jsx to explicitly check for and catch the string variants of "null" and "undefined", correctly intercepting the bad state and forcing the user to the login screen instead of crashing the backend connection.

@vercel

vercel Bot commented May 24, 2026

Copy link
Copy Markdown

@basantnema31 is attempting to deploy a commit to the swapnilsingh99's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, @basantnema31! 🎉 Thank you for submitting your pull request. Your contribution is valuable and we appreciate your efforts to improve our project.

We will promptly review your changes and offer feedback. Keep up the excellent work! Kindly remember to check our contributing guidelines

@basantnema31 basantnema31 closed this by deleting the head repository May 27, 2026
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: NULL data is send at backend when webpage will load which causes Error and page will not render

1 participant