* fix 401 redirect in auth routes (#674)

* fix config getter
This commit is contained in:
Philip Okugbe
2025-01-26 14:01:08 +00:00
committed by GitHub
parent 990612793f
commit 85159a2c95
2 changed files with 39 additions and 44 deletions
+11 -8
View File
@@ -1,5 +1,5 @@
import axios, { AxiosInstance } from "axios";
import Routes from "@/lib/app-route.ts";
import APP_ROUTE from "@/lib/app-route.ts";
const api: AxiosInstance = axios.create({
baseURL: "/api",
@@ -41,8 +41,8 @@ api.interceptors.response.use(
.includes("workspace not found")
) {
console.log("workspace not found");
if (window.location.pathname != Routes.AUTH.SETUP) {
window.location.href = Routes.AUTH.SETUP;
if (window.location.pathname != APP_ROUTE.AUTH.SETUP) {
window.location.href = APP_ROUTE.AUTH.SETUP;
}
}
break;
@@ -58,11 +58,14 @@ api.interceptors.response.use(
);
function redirectToLogin() {
if (
window.location.pathname != Routes.AUTH.LOGIN &&
window.location.pathname != Routes.AUTH.SIGNUP
) {
window.location.href = Routes.AUTH.LOGIN;
const exemptPaths = [
APP_ROUTE.AUTH.LOGIN,
APP_ROUTE.AUTH.SIGNUP,
APP_ROUTE.AUTH.FORGOT_PASSWORD,
APP_ROUTE.AUTH.PASSWORD_RESET,
];
if (!exemptPaths.some((path) => window.location.pathname === path)) {
window.location.href = APP_ROUTE.AUTH.LOGIN;
}
}