Skip to content

Commit 3372941

Browse files
committed
fix: route handling on 401
1 parent 8454e74 commit 3372941

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/main.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ axios.defaults.withXSRFToken = true;
2727
axios.defaults.withCredentials = true;
2828
// Set accept header
2929
axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";
30-
axios.defaults.baseURL = import.meta.env.VITE_API_URL;
30+
// axios.defaults.baseURL = import.meta.env.VITE_API_URL;
3131

3232
axios.interceptors.response.use(
3333
(response) => response,
@@ -37,6 +37,8 @@ axios.interceptors.response.use(
3737
router.push({ name: "login-otp" });
3838
} else if (error.response?.status === 429) {
3939
router.push({ name: "429" });
40+
} else if (error.response?.status === 401) {
41+
router.push({ name: "login" });
4042
}
4143
return Promise.reject(error);
4244
}

src/router/gates/auth.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default class extends baseGate {
1717
route(): false | RouteLocationRaw {
1818
// If the route was supposed to be login-otp, we should redirect to login-otp, else just login
1919
return {
20-
name: "login/otp",
20+
name: "login-otp",
2121
};
2222
}
2323
}

0 commit comments

Comments
 (0)