mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-17 10:11:03 +10:00
updates and fixes
* seo friendly urls * custom client serve-static module * database fixes * fix recent pages * other fixes
This commit is contained in:
@ -38,15 +38,22 @@ api.interceptors.response.use(
|
||||
switch (error.response.status) {
|
||||
case 401:
|
||||
// Handle unauthorized error
|
||||
if (window.location.pathname != Routes.AUTH.LOGIN) {
|
||||
window.location.href = Routes.AUTH.LOGIN;
|
||||
}
|
||||
Cookies.remove("authTokens");
|
||||
redirectToLogin();
|
||||
break;
|
||||
case 403:
|
||||
// Handle forbidden error
|
||||
break;
|
||||
case 404:
|
||||
// Handle not found error
|
||||
if (
|
||||
error.response.data.message
|
||||
.toLowerCase()
|
||||
.includes("workspace not found")
|
||||
) {
|
||||
Cookies.remove("authTokens");
|
||||
redirectToLogin();
|
||||
}
|
||||
break;
|
||||
case 500:
|
||||
// Handle internal server error
|
||||
@ -59,4 +66,13 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
export default api;
|
||||
|
||||
Reference in New Issue
Block a user