wepack配置之devServer.proxy

"api/a/b/c/d": {
  target: 'http://www.baidu.com',
  bypass: function (req, res, proxyOptions) {
    console.log(req.headers, '===========req===========');
  },
  headers: {
    //是否允许后续请求携带认证信息(cookies)
    'Access-Control-Allow-Credentials':'true',
    Cookie: 'xxx'
  },
  changeOrigin: true
},

本地开发暂时使用用线上接口:localhost:9000/api/a/b/c/d  => http://www.b aidu.com/api/a/b/c/d

原文地址:https://www.cnblogs.com/CassieHouse/p/14592178.html