在uView(uni-app)中配置h5的请求代理

411 阅读1分钟

经测试,在 vue.config.js 文件中写的配置并不起作用,需要在manifest.json中配置

// 在manifest.json中配置代理,如
"devServer": {
    "disableHostCheck": true,
    "proxy": {
        "/api": {
            "target": "http://edu.yunlimall.cn",
            "changeOrigin": true,
            "secure": false
         }
    }
},
请求的时候代理的是/api部分,url = "/api/getUser"
// publicPath需要在router中配置
"router": {
    "mode": hash,
    "base": "/XXXXXXXX"
}