proxy.ts 355 B

123456789101112131415
  1. type ProxyItem = [string, string];
  2. type ProxyList = ProxyItem[];
  3. export function createProxy(list: ProxyList = []) {
  4. const ret: any = {};
  5. for (const [prefix, target] of list) {
  6. ret[prefix] = {
  7. target: target,
  8. changeOrigin: true,
  9. rewrite: (path: string) => path.replace(new RegExp(`^${prefix}`), ''),
  10. };
  11. }
  12. return ret;
  13. }