Browse Source

【更改接口拦截】

master
GL 4 years ago
parent
commit
f3515c2b84
2 changed files with 20 additions and 19 deletions
  1. +19
    -18
      src/services/utils.js
  2. +1
    -1
      vue.config.js

+ 19
- 18
src/services/utils.js View File

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


// 匹配接口前缀 // 匹配接口前缀
export function autoMatch (prefix) { 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; return baseUrl;
} }




+ 1
- 1
vue.config.js View File

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


Loading…
Cancel
Save