uniapp解决跨域方案
2021-10-16 本文已影响0人
宏_4491
方案1:manifest.json配置
"h5": {
"devServer": {
"port": 9991,
"disableHostCheck": true,
"proxy": {
"/api": {
"target": "http://172.17.100.203:9991", //代理目标
"secure": false, //是否开启支持https
"pathRewrite": {
"^/api": "" //遇到/api 开头转化成“”
}
}
}
}
}
创建vue.config.js配置
module.exports = {
devServer: {
proxy: {
"/api":: {
target: "http://172.17.100.203:9991",
pathRewrite: {
'^/api': ''
}
}
},
}
}
image.png安装Chrome 插件 Allow CORS: Access-Control-Allow-Origin