fix(auth redirect fixed)
This commit is contained in:
@@ -4,7 +4,7 @@ const API_BASE_URL = import.meta.env.VITE_API_BASE_URL_BACKEND ?? "";
|
|||||||
|
|
||||||
async function throwIfResNotOk(res: Response) {
|
async function throwIfResNotOk(res: Response) {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
if (res.status === 401) {
|
if (res.status === 401 || res.status === 403) {
|
||||||
localStorage.removeItem("token");
|
localStorage.removeItem("token");
|
||||||
if (!window.location.pathname.startsWith("/auth")) {
|
if (!window.location.pathname.startsWith("/auth")) {
|
||||||
window.location.href = "/auth";
|
window.location.href = "/auth";
|
||||||
@@ -109,7 +109,10 @@ export const getQueryFn: <T>(options: {
|
|||||||
credentials: "include",
|
credentials: "include",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (unauthorizedBehavior === "returnNull" && res.status === 401) {
|
if (
|
||||||
|
unauthorizedBehavior === "returnNull" &&
|
||||||
|
(res.status === 401 || res.status === 403)
|
||||||
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user