林场巡检管理
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
492B

  1. const httpsRE = /^https:\/\//
  2. export function createProxy(list = []) {
  3. const ret = {}
  4. for (const [prefix, target] of list) {
  5. const isHttps = httpsRE.test(target)
  6. // https://github.com/http-party/node-http-proxy#options
  7. ret[prefix] = {
  8. target: target,
  9. changeOrigin: true,
  10. ws: true,
  11. rewrite: (path) => path.replace(new RegExp(`^${prefix}`), ''),
  12. // https is require secure=false
  13. ...(isHttps ? { secure: false } : {})
  14. }
  15. }
  16. return ret
  17. }