0
点赞
收藏
分享

微信扫一扫

vue proxytable 代理根路径的同时增加其他代理

萨摩斯加士奇 2022-03-10 阅读 79

Vue 项目有一个需求,需要对根路径 ‘/’ 进行代理,但同时还存在其余特例路径的访问需求 ‘/py’,例:

  • 代理 /* 到 localhost:5000
  • 代理 /py/*到 localhost:5001

此时,需要将特例路径的代理写在根路径的前面,否则会被根路径的代理覆盖,无法成功进行代理:

module.exports = {
  dev: {
    proxyTable: {
      '/py': {
        target: `localhost:5001`,
        changeOrigin: true,
        pathRewrite: {
          '/py': '',
        }
      },
      '/': {
        target: `localhost:5000`,
        // secure: true, // 是否 https
        changeOrigin: true, // 是否是跨域请求
      }
    }
  }
}
举报

相关推荐

0 条评论