flat:暂存

This commit is contained in:
Apcallover
2025-11-28 19:14:42 +08:00
parent e6543185ab
commit 38ae671ea9
2 changed files with 12 additions and 7 deletions

View File

@@ -231,6 +231,13 @@ export const request = {
const authHeader = headers['Authorization'];
const isToken = headers['isToken'];
// 处理开发环境API路径
if (process.env.NODE_ENV !== 'development') {
if (url.startsWith('/api')) {
url = url.replace(/^\/api/, '');
}
}
// 处理认证token
if (!authHeader && isToken !== false) {
const expireTime = getTokenExpireTime();
@@ -295,13 +302,6 @@ export const request = {
};
}
// 处理开发环境API路径
if (process.env.NODE_ENV !== 'development') {
if (url.startsWith('/api')) {
url = url.replace(/^\/api/, '');
}
}
return { url, options: { ...options, headers } };
},
],

View File

@@ -88,6 +88,11 @@ export const errorConfig: RequestConfig = {
// 请求拦截器
requestInterceptors: [
/**
* 拦截并修改请求配置添加token参数
* @param {RequestOptions} config - 原始请求配置对象
* @returns {RequestOptions} 修改后的请求配置对象包含添加的token参数
*/
(config: RequestOptions) => {
// 拦截请求配置,进行个性化处理。
const url = config?.url?.concat('?token = 123');