技术碎片
技术记录
帮助交流
uni-app H5 nginx下运行跨域问题处理
直接放处理办法:
manifest.json尾部加入
// h5端跨域配置
"h5": {
"devServer": {
"port": 80,
"disableHostCheck": true,
"proxy": {
"/dpc": {
"target": "http://api.heclouds.com",//你的API接口地址
"changeOrigin": true,
"secure": false,
"pathRewrite":{"^/dpc":""}
}
}
}
},
请求处填入:
uni.request({
url:"/dpc/data",//请求地址填入代理地址
method:'POST',
data:this.datas,
success:(res) =>{
// console.log(res)
}
})
nginx配置文件处添加
location /dpc{
proxy_pass http://api.heclouds.com;
}
至此跨域问题处理完毕
如有疑问或者交流问题请加:QQ 2137087126
转载请注明来源地址:www.zhyunxuan.com>
更新时间 2023-02-01
 3014
梦想有多远,路就有多远