首页 > 解决方案 > 如何在 Vue.js 中使用不同的端口和相同的路径设置多个代理

问题描述

所以,我试图弄清楚如何代理到具有不同端口和相同路径的不同服务器。

xxx.vue:

  axios.get('/actuator/health/')
    .then(response => this.status = response.data.status)
    .catch(err => console.log(err.message))

这是我的 config.vue.js :

module.exports = {
devServer: {
  proxy: {
    '^/actuator/': {
      target: 'http://localhost:59400/',
      changeOrigin: true,
      secure:false,
      pathRewrite: {'^/actuator': '/actuator/'},
      logLevel: 'debug'
    }
  }
}

}

我想用相同的路径从端口 8787 获取数据:

http://localhost:8787/actuator/health

我该怎么做?如果我不能改变路径。

标签: vue.jsvuejs2proxyaxios

解决方案


推荐阅读