fix(configui): return to login only when invalid token to missing auth header (#5014)
diff --git a/config-ui/src/utils/request.ts b/config-ui/src/utils/request.ts
index 2fb8ba5..d0b31ff 100644
--- a/config-ui/src/utils/request.ts
+++ b/config-ui/src/utils/request.ts
@@ -51,13 +51,18 @@
} else {
params.data = data;
}
+ const missingAuthHeader = 'Authorization header is missing';
+ const invalidToken = 'Invalid token';
instance.interceptors.response.use(
(response) => response,
(error) => {
if (error.response && error.response.status === 401) {
- toast.error('Please log in first');
- history.push('/login');
+ // only handle when data contains missingAuthHeader or invalidToken
+ if (error.response.data.includes(missingAuthHeader) || error.response.data.includes(invalidToken)) {
+ toast.error('Please login first');
+ history.push('/login');
+ }
}
},
);