manifest.json 源码配置:
"h5": {
"router": {
"mode": "history"
},
"devServer": {
"port": 8000,
"disableHostCheck": true,
"proxy": {
"/api": {
"target": "http://**.com", //目标接口域名
"changeOrigin": true, //是否跨域
"secure": false ,// 设置支持https协议的代理
"pathRewrite":{
"^/api":""
}
}
}
}
}
request 请求:
uni.request({ //url: "/my/list"
url: "/api" + url,
data: data,
method:type||"GET",
header: {
'content-type': 'application/x-www-form-urlencoded',
},
success: (res) => {
},
fail: (res) => {
}
});