vue devServer proxy 代理无效的问题

在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

posted @ 2020-06-06 11:56  会飞的鱼9999  阅读(14499)  评论(0编辑  收藏  举报