mirror of
https://github.com/docmost/docmost.git
synced 2026-05-18 23:44:24 +08:00
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user