瀏覽代碼

【更改接口拦截】

master
GL 4 年之前
父節點
當前提交
f3515c2b84
共有 2 個文件被更改,包括 20 次插入19 次删除
  1. +19
    -18
      src/services/utils.js
  2. +1
    -1
      vue.config.js

+ 19
- 18
src/services/utils.js 查看文件

@@ -7,24 +7,25 @@ const isDev = process.env.NODE_ENV === 'development'; // 开发 or 生产

// 匹配接口前缀
export function autoMatch (prefix) {
let baseUrl = `/${prefix || 'fumao'}`;
// if (isDev) {
// // 开发环境 通过proxy配置转发请求;
// baseUrl = `/${prefix || 'fumao'}`;
// } else {
// // 生产环境 根据实际配置 根据 prefix 匹配url;
// // 配置来源 根据实际应用场景更改配置。(1.从全局读取;2.线上配置中心读取)
// switch (prefix) {
// case 'baidu':
// baseUrl = window.LOCAL_CONFIG.baidu;
// break;
// case 'alipay':
// baseUrl = window.LOCAL_CONFIG.alipay;
// break;
// default:
// baseUrl = window.LOCAL_CONFIG.default;
// }
// }
let baseUrl = ``;
if (isDev) {
// 开发环境 通过proxy配置转发请求;
baseUrl = `/${prefix || 'fumao'}`;
} else {
// 生产环境 根据实际配置 根据 prefix 匹配url;
// 配置来源 根据实际应用场景更改配置。(1.从全局读取;2.线上配置中心读取)
// switch (prefix) {
// case 'baseurl':
// baseUrl = window.LOCAL_CONFIG.baseurl;
// break;
// case 'fumao':
// baseUrl = window.LOCAL_CONFIG.fumao;
// break;
// default:
// baseUrl = window.LOCAL_CONFIG.default;
// }
baseUrl = `/${prefix || 'fumao'}`;
}
return baseUrl;
}



+ 1
- 1
vue.config.js 查看文件

@@ -20,7 +20,7 @@ module.exports = {
}
},
'/fumao': {
target: 'https://btest.malls.iformall.com/B',
target: 'https://bh5test.malls.iformall.com/B',
changeOrigin: true,
pathRewrite: {
'^/fumao': ''


Loading…
取消
儲存