Skip to content

Commit e383417

Browse files
committed
fix: silence csrf forbidden toast
1 parent bea4bfe commit e383417

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

frontend/src/api/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ const config = {
1818
withCredentials: true,
1919
};
2020

21+
const isCsrfForbidden = (response?: AxiosResponse<any>) => {
22+
const message = response?.data?.message;
23+
return typeof message === 'string' && message.toLowerCase().includes('csrf token invalid');
24+
};
25+
2126
class RequestHttp {
2227
service: AxiosInstance;
2328
public constructor(config: AxiosRequestConfig) {
@@ -118,6 +123,9 @@ class RequestHttp {
118123
router.push({ name: 'Expired' });
119124
return;
120125
case 403:
126+
if (isCsrfForbidden(response)) {
127+
return Promise.reject(error);
128+
}
121129
if (response.data && response.data['message']) {
122130
MsgError(response.data['message']);
123131
} else {

0 commit comments

Comments
 (0)