注=== 仅支持本地调试使用,,,正式时候需要后台支持,如果同域名下面默认支持
准备两个hostUrl
var hostUrl = "https://xxxxx.com"
// 本地调试的时候
var isDebug = true
if (isDebug) {
hostUrl = "/DebugApi"
}
function getApi(since_id,callBack){
let url = hostUrl + '/xx/xx'
// since_id
uni.request({
url:url,
data:{
since_id:since_id
},
method:"POST",
success: (res) => {
console.log(res.data.data)
callBack(res.data.data)
}
})
}
找到mainfest.json 源码打开粘贴进去即可
"h5" : {
"title" : "",
"router" : {
"mode" : "hash"
},
"devServer" : {
"port" : 8080,
"https" : false,
"disableHostCheck" : true,
"proxy": {
"/DebugApi": {
"target": "https://xxxxx.com", // 你的目标接口域名
"changeOrigin": true,
"secure": true,
"pathRewrite" : {
"^/DebugApi" : ""
}
}
}
}
}
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。