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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM