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"); }