!866 fix: 修复请求拦截器bug

Merge pull request !866 from funcong/fc-fix-bug
pull/870/MERGE
芋道源码 2026-05-03 10:37:47 +00:00 committed by Gitee
commit aafe5f12bc
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 10 additions and 7 deletions

View File

@ -50,13 +50,16 @@ const service: AxiosInstance = axios.create({
service.interceptors.request.use(
(config: InternalAxiosRequestConfig) => {
// 是否需要设置 token
let isToken = (config!.headers || {}).isToken === false
whiteList.some((v) => {
if (config.url && config.url.indexOf(v) > -1) {
return (isToken = false)
}
})
if (getAccessToken() && !isToken) {
let isToken = (config!.headers || {}).isToken !== false
if (config.url && isToken) {
whiteList.some((v) => {
if (config.url.includes(v)) {
isToken = false
return true // 终止循环
}
})
}
if (getAccessToken() && isToken) {
config.headers.Authorization = 'Bearer ' + getAccessToken() // 让每个请求携带自定义token
}
// 设置租户