vue devServer proxy 代理無效的問題

在vue.config.js中,設置javascript

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:88vue

相關文章
相關標籤/搜索