Browse Source

新增本地代理模式

master
453530270@qq.com 2 years ago
parent
commit
d6bb40205f
  1. 4
      api/goods.js
  2. 5
      config.js
  3. 15
      manifest.json
  4. 11
      utils/request/index.js

4
api/goods.js

@ -1,8 +1,8 @@
import request from '@/utils/request' import request from '@/utils/request'
// 生成环境和测试环境相同 // 生成环境和测试环境相同
// const prefix ="AgencyAddress/" const prefix ="AgencyAddress/"
const prefix=""; // const prefix="";
// api地址 // api地址

5
config.js

@ -8,9 +8,10 @@ module.exports = {
//apiUrl: "http://192.168.66.16:8089/index.php?s=/api/", //apiUrl: "http://192.168.66.16:8089/index.php?s=/api/",
// dev env // dev env
// apiUrl: "http://58.30.231.137:8022/", // apiUrl: "http://58.30.231.137:8022/",
apiUrl: "http://10.24.4.156/api/", // apiUrl: "http://10.24.4.156/api/",
// product env // product env
// apiUrl: "http://10.24.4.14:80/", // apiUrl: "http://10.24.4.14:80/kk",
apiUrl: "./kk/",
/** /**
* 是否启用商城设置缓存 * 是否启用商城设置缓存

15
manifest.json

@ -106,6 +106,21 @@
"router" : { "router" : {
"mode" : "history", "mode" : "history",
"base" : "./" "base" : "./"
},
"devServer": {
"https": false,
"disableHostCheck" : true,
// "port": 8080,
"proxy":{
"/kk" : {
"target" : "http://10.24.4.14", //
"changeOrigin" : true,
"secure" : true,
"pathRewrite" : {
"^/kk" : "/"
}
}
}
} }
} }
} }

11
utils/request/index.js

@ -18,7 +18,7 @@ const $http = new request({
// defaultUploadUrl: 'upload/image', // defaultUploadUrl: 'upload/image',
// 设置请求头(如果使用报错跨域问题,可能是content-type请求类型和后台那边设置的不一致) // 设置请求头(如果使用报错跨域问题,可能是content-type请求类型和后台那边设置的不一致)
header: { header: {
'Content-Type': 'application/json;charset=utf-8' 'Content-Type': 'application/json;charset=UTF-8'
}, },
// 请求超时时间, 单位ms(默认15000) // 请求超时时间, 单位ms(默认15000)
timeout: 15000, timeout: 15000,
@ -64,13 +64,14 @@ $http.requestStart = options => {
} }
} }
// 请求前加入当前终端 // 请求前加入当前终端
options.header['platform'] = store.getters.platform //options.header['platform'] = store.getters.platform
// //
options.header['Accept'] = "application/json;charset=UTF-8" options.header['Accept'] = "application/json;charset=UTF-8"
// 请求前加入Token // 请求前加入Token
if(store.getters.token){ // if(store.getters.token){
options.header['normal_login_token'] = store.getters.token // options.header['normal_login_token'] = store.getters.token
} // }
// return false 表示请求拦截,不会继续请求 // return false 表示请求拦截,不会继续请求
return options return options
} }

Loading…
Cancel
Save