diff --git a/src/client/web-client/index.ts b/src/client/web-client/index.ts index 1946987..5ad7e95 100644 --- a/src/client/web-client/index.ts +++ b/src/client/web-client/index.ts @@ -9,16 +9,11 @@ const webClient = axios.create({ baseURL: import.meta.env.VITE_API_BASE_URL, timeout: dayjs.duration({ seconds: 10 }).asMilliseconds(), withCredentials: true, - withXSRFToken: true + withXSRFToken: true, }) webClient.interceptors.request.use( (config) => { - const state = store.getState() - if (state.auth.isAuthenticated) { - config.headers["Authorization"] = `Bearer ${state.auth.token!}` - } - return config }, (error: unknown) => { diff --git a/src/store/auth-slice/index.ts b/src/store/auth-slice/index.ts index 0c58e44..ee912ad 100644 --- a/src/store/auth-slice/index.ts +++ b/src/store/auth-slice/index.ts @@ -4,14 +4,12 @@ import type { User } from "@/types/entity" interface AuthState { isAuthenticated: boolean user: User | null - token: string | null, registrationEnabled: boolean } const initialState: AuthState = { isAuthenticated: false, user: null, - token: null, registrationEnabled: false } @@ -23,18 +21,15 @@ const authSlice = createSlice({ state, action: PayloadAction<{ user: User - token: string }> ) { console.log("更新用户信息:", action.payload.user) state.isAuthenticated = true state.user = action.payload.user - state.token = action.payload.token }, logout(state) { state.isAuthenticated = false state.user = null - state.token = null }, updateRegistrationEnabled(state, action: PayloadAction) { state.registrationEnabled = action.payload