forked from github/plane
fix: handled token expiry validation (#1016)
This commit is contained in:
parent
a1de3f581f
commit
a69593a9e8
@ -1,6 +1,21 @@
|
||||
import axios from "axios";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
const unAuthorizedStatus = [401];
|
||||
axios.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => {
|
||||
const { status }: any = error.response;
|
||||
if (unAuthorizedStatus.includes(status)) {
|
||||
Cookies.remove("refreshToken", { path: "/" });
|
||||
Cookies.remove("accessToken", { path: "/" });
|
||||
console.log("window.location.href", window.location.pathname);
|
||||
if (window.location.pathname != "/signin") window.location.href = "/signin";
|
||||
}
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
abstract class APIService {
|
||||
protected baseURL: string;
|
||||
protected headers: any = {};
|
||||
|
Loading…
Reference in New Issue
Block a user