我的 uniapp 代码是用cli 生成的,电脑没有安装HBuilderX
调用接口 出现 Provisional headers are shown 或者 Status Code: 403 Forbidden,都是跨域问题
manifest.json 加配置
"h5": { "devServer": { "port": 8888, "disableHostCheck": true, "proxy": { "/api": { "target": "http://api.xxx.com", "changeOrigin": true, "secure": false, } } } },
以上配置,实际请求接口前默认会有 'http://aa.com/api'
也可以去掉api
"h5": { "devServer": { "port": 8888, "disableHostCheck": true, "proxy": { "/": { "target": "http://api.xxx.com", "changeOrigin": true, "secure": false } } } },
参见:https://blog.csdn.net/sayyy/article/details/106269732
.