fix: silence csrf forbidden toast (#12461)

This commit is contained in:
ssongliu
2026-04-09 22:23:47 +08:00
committed by GitHub
parent bea4bfeee8
commit 04fd456b63
+8
View File
@@ -18,6 +18,11 @@ const config = {
withCredentials: true,
};
const isCsrfForbidden = (response?: AxiosResponse<any>) => {
const message = response?.data?.message;
return typeof message === 'string' && message.toLowerCase().includes('csrf token invalid');
};
class RequestHttp {
service: AxiosInstance;
public constructor(config: AxiosRequestConfig) {
@@ -118,6 +123,9 @@ class RequestHttp {
router.push({ name: 'Expired' });
return;
case 403:
if (isCsrfForbidden(response)) {
return Promise.reject(error);
}
if (response.data && response.data['message']) {
MsgError(response.data['message']);
} else {