williamyorkl/vite-plugin-proxy-middleware

按demo配置无效

Closed this issue · 1 comments

这些代码是干什么用的,dev, test这些看起来像env的key是按什么规则,完全没有文档,源码里也只有
if (req.originalUrl.includes(proxyPath)) 看起来完全不会匹配上

module.exports = {
  dev: {
    "/admin": {
      target: "http://xxx-dev.com/",
      rewrite: (path) => path.replace(/^\/admin/, ""),
    },
  },
  test: {
    "/admin": {
      target: "http://xxx-test.com/",
      rewrite: (path) => path.replace(/^\/admin/, ""),
    },
  },
  gray: {
    "/admin": {
      target: "http://xxx-gray.com",
      rewrite: (path) => path.replace(/^\/admin/, ""),
    },
  },
  prod: {
    "/admin": {
      target: "http://xxx-prod.com",
      rewrite: (path) => path.replace(/^\/admin/, ""),
    },
  },
};
  1. 项目需要先本地配置https(demo项目就算里面有证书,也要你自己添加到自己本地,所以还不如你自己生成)
  2. proxyPath是一个指定代理表文件的地址路径,以上你指明的代码就是一个demo的代理表example