提交 d5f9919b 编写于 作者: J JinMao

fix: fix defHttp baseUrl work

上级 aed622bd
......@@ -80,6 +80,7 @@ const transform: AxiosTransform = {
// 请求之前处理config
beforeRequestHook: (config, options) => {
const { baseURL } = config;
const { apiUrl, joinPrefix, joinParamsToUrl, formatDate, joinTime = true } = options;
if (joinPrefix) {
......@@ -89,6 +90,9 @@ const transform: AxiosTransform = {
if (apiUrl && isString(apiUrl)) {
config.url = `${apiUrl}${config.url}`;
}
if (baseURL && isString(baseURL)) {
config.url = `${baseURL}${config.url}`;
}
const params = config.params || {};
if (config.method?.toUpperCase() === RequestEnum.GET) {
if (!isString(params)) {
......@@ -186,7 +190,7 @@ function createAxios(opt?: Partial<CreateAxiosOptions>) {
authenticationScheme: '',
timeout: 10 * 1000,
// 基础接口地址
// baseURL: globSetting.apiUrl,
baseURL: globSetting.apiUrl,
// 接口可能会有通用的地址部分,可以统一抽取出来
urlPrefix: urlPrefix,
headers: { 'Content-Type': ContentTypeEnum.JSON },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册