From 223a41d91b39769130241c5456a9f8fdec9c74fb Mon Sep 17 00:00:00 2001 From: basantnema31 Date: Sun, 24 May 2026 15:25:49 +0530 Subject: [PATCH] fix: prevent sending string 'null' or 'undefined' tokens to backend (Issue #257) --- client/src/Context/UserContext.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/Context/UserContext.jsx b/client/src/Context/UserContext.jsx index d5192cf..32c4c47 100644 --- a/client/src/Context/UserContext.jsx +++ b/client/src/Context/UserContext.jsx @@ -25,8 +25,8 @@ export const UserContextProvider = ({ children }) => { const getUser = async () => { const token = localStorage.getItem("token"); - // If no token and not on a public route, redirect to login - if (!token) { + // If no token (or invalid string "null"/"undefined") and not on a public route, redirect to login + if (!token || token === "null" || token === "undefined") { if (!isPublicRoute) { navigate("/login"); }