5
//webpack.config.js
proxy: {
            '/drink': {
                target: "http://xxx.26.xx.75:8010/channelFreeDrink/",
                changeOrigin:true,
                pathRewrite: {
                    '^/drink': ''
                }
            }
      }
//api.js
const sourcelist = ()=>{
    return new Promise((resolve,reject)=>{
        // fetch(window.YY_API + '/channelFreeDrink/activity').then(res => {
        fetch('/drink/activity').then(res => {
            if(res.status==200) return res.json()
        }).then(data=>{
            resolve(data)
        })
    })
}

图片描述
图中黄框跟黄框所对应(/drink),白框(/activity)在代理请求的时候会加在target所指的链接后面


stick
124 声望3 粉丝