π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
[WEB-1564] chore: add interceptor to handle 401 errors and redirect users to login page. (#4788)
Prateek Shourya47dfb8797fbb
diff --git a/web/core/services/api.service.ts b/web/core/services/api.service.tsindex c80f71017b..0886fe9b0d 100644--- a/web/core/services/api.service.ts+++ b/web/core/services/api.service.ts@@ -11,6 +11,20 @@ export abstract class APIService {baseURL,withCredentials: true,});++ this.setupInterceptors();+ }++ private setupInterceptors() {+ this.axiosInstance.interceptors.response.use(+ (response) => response,+ (error) => {+ if (error.response && error.response.status === 401) {+ window.location.reload();+ }+ return Promise.reject(error);+ }+ );}get(url: string, params = {}, config = {}) {diff --git a/web/core/services/user.service.ts b/web/core/services/user.service.tsindex 9202da9fe4..6c75de94c2 100644--- a/web/core/services/user.service.ts+++ b/web/core/services/user.service.ts@@ -46,7 +46,8 @@ export class UserService extends APIService {}async currentUser(): Promise<IUser> {- return this.get("/api/users/me/")+ // Using validateStatus: null to bypass interceptors for unauthorized errors.+ return this.get("/api/users/me/", { validateStatus: null }).then((response) => response?.data).catch((error) => {throw error?.response;