diff --git a/src/Utils/request/handleResponse.ts b/src/Utils/request/handleResponse.ts index 9f85b50a68d..905417ad0e2 100644 --- a/src/Utils/request/handleResponse.ts +++ b/src/Utils/request/handleResponse.ts @@ -20,14 +20,15 @@ export default function handleResponse( // Other Errors between 400-599 (inclusive) if (res.status >= 400 && res.status < 600) { - // Invalid token - if (!silent && error?.code === "token_not_valid") { - navigate(`/session-expired?redirect=${window.location.href}`); - } - - // Handle session expiry - if (error?.detail === "Authentication credentials were not provided.") { - notify?.Error({ msg: "Session expired. Please Login again." }); + // Handle invalid token / session expiry + if ( + !silent && + (error?.code === "token_not_valid" || + error?.detail === "Authentication credentials were not provided.") + ) { + if (!location.pathname.startsWith("/session-expired")) { + navigate(`/session-expired?redirect=${window.location.href}`); + } return; }