首页 > 其他 > 详细

vue devServer proxy 代理无效的问题

时间:2020-06-06 14:25:03      阅读:266      评论:0      收藏:0      [点我收藏+]

在vue.config.js中,设置

module.exports = {
  publicPath: ‘/app‘,
  devServer: {
    proxy: {
      ‘/test‘: {
        target: ‘http://localhost:88‘,
        ws: true,
        changeOrigin: true,
        pathRewrite: {
          ‘^/test‘: ‘/‘, // rewrite path
        },
      }
    }
  }
}
axios中
this.axios.post(‘/test‘).then(value => {
        console.log(value);
      })

  这样设置后,却访问不到,原因是,后台也要有 test字段,  这样设置后,后台访问的URL为: http://localhost:88/test  ,而不是  http://localhost:88

vue devServer proxy 代理无效的问题

原文:https://www.cnblogs.com/ztgzlu/p/13054141.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!