我的 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
.
