From a5b7207f44acccdcde31bb6351c0d30227cf213b Mon Sep 17 00:00:00 2001 From: wuxichen <17301714657@163.com> Date: Mon, 13 Oct 2025 17:01:18 +0800 Subject: [PATCH] fix: authorization --- src/app.tsx | 2 +- src/requestErrorConfig.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index 00649f3..d76f953 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -188,7 +188,7 @@ export const request: RequestConfig = { }; // 如果有token,则添加Authorization头 if (token) { - headers.Authorization = `Bearer·${getAccessToken()}`; + headers.Authorization = `Bearer ${getAccessToken()}`; } return { url, options: { ...options, headers } }; }, diff --git a/src/requestErrorConfig.ts b/src/requestErrorConfig.ts index 0fb6470..b4a7d28 100644 --- a/src/requestErrorConfig.ts +++ b/src/requestErrorConfig.ts @@ -178,7 +178,9 @@ export const errorConfig: RequestConfig = { // 2.1 刷新成功,则回放队列的请求 + 当前请求 setToken(refreshTokenRes); // 发出 token 刷新事件 - requestEventBus.emit('token-refreshed'); + // 刷新当前路由 + // window.location.reload(); + // requestEventBus.emit('token-refreshed'); } catch (_) { // 为什么需要 catch 异常呢?刷新失败时,请求因为 Promise.reject 触发异常。 // 提示是否要登出。即不回放当前请求!不然会形成递归