fix: original url containe empty strings (#1414)

Co-authored-by: sealday <sealday@gmail.com>
Reviewed-on: daoyoucloud/tachybase#1414
This commit is contained in:
sealday 2024-07-31 14:29:41 +08:00
parent 4cee56eed7
commit 2666fc045c

View File

@ -18,8 +18,9 @@ export type RequestConfig = Pick<AxiosRequestConfig, 'url' | 'method' | 'params'
async function request(config, context) {
// default headers
const { token, origin } = context;
const { url: originUrl, method = 'POST', data, timeout = 5000 } = config;
const { method = 'POST', data, timeout = 5000 } = config;
const originUrl = (config.url?.url || '').trim();
const url = originUrl.startsWith('http') ? originUrl : `${origin}${originUrl}`;
let headers = (config.headers ?? []).reduce((result, header) => {