∞拾年

uni-app 设置代理 解决跨域问题
1、在mainfest.js中加入代码段注:“pathRewrite”:{"^/api":""} 不设置则代理不起...
扫描右侧二维码阅读全文
31
2019/12

uni-app 设置代理 解决跨域问题

1、在mainfest.js中加入代码段

注:“pathRewrite”:{"^/api":""} 不设置则代理不起效

  "h5": {
  "devServer": {
      "port": 8080,
      "disableHostCheck": true,
      "proxy": {
          "/api": {
              "target": "http://Ip:port",
              "changeOrigin": true,
              "secure": false,
              "pathRewrite":{"^/api":""}
          }
      }
  }

2.在请求的时候直接用api代替即可

Last modification:December 31st, 2019 at 09:53 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment