//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所指的連接後面webpack