feat: add VITE_APP_PROXY 控制H5代理

This commit is contained in:
菲鸽
2024-05-18 17:24:21 +08:00
parent 4789b5ba41
commit b83541d483
5 changed files with 34 additions and 8 deletions

View File

@@ -27,7 +27,18 @@ const httpInterceptor = {
}
// 非 http 开头需拼接地址
if (!options.url.startsWith('http')) {
// #ifdef H5
console.log(__VITE_APP_PROXY__)
if (JSON.parse(__VITE_APP_PROXY__)) {
// 啥都不需要做
} else {
options.url = baseUrl + options.url
}
// #endif
// 非H5正常拼接
// #ifndef H5
options.url = baseUrl + options.url
// #endif
// TIPS: 如果需要对接多个后端服务,也可以在这里处理,拼接成所需要的地址
}
// 1. 请求超时