fix(web): clear stale auth before workspace load

This commit is contained in:
Xiaoxia AI
2026-06-22 20:41:48 +08:00
parent fb633a8ed4
commit 14f72dbb50
2 changed files with 5 additions and 3 deletions
+2 -2
View File
@@ -3,6 +3,7 @@
* 封装 Axios 实例,配置拦截器和 Token 管理
*/
import axios, { AxiosError, InternalAxiosRequestConfig } from 'axios';
import { useAuthStore } from '@/store/authStore';
// 创建 Axios 实例
const apiClient = axios.create({
@@ -32,8 +33,7 @@ apiClient.interceptors.response.use(
(response) => response,
async (error: AxiosError) => {
if (error.response?.status === 401) {
localStorage.removeItem('access_token');
localStorage.removeItem('refresh_token');
useAuthStore.getState().clearAuth();
}
return Promise.reject(error);