vben
2020-10-18 7101587b9676c91e9079044a096df08848f1f602
提交 | 用户 | age
2f6253 1 type ProxyItem = [string, string];
2
3 type ProxyList = ProxyItem[];
4
710158 5 const reg = /^https:\/\//;
526e6c 6 export function createProxy(list: ProxyList = []) {
2f6253 7   const ret: any = {};
8   for (const [prefix, target] of list) {
710158 9     const isHttps = reg.test(target);
V 10
2f6253 11     ret[prefix] = {
12       target: target,
13       changeOrigin: true,
14       rewrite: (path: string) => path.replace(new RegExp(`^${prefix}`), ''),
710158 15       ...(isHttps ? { secure: false } : {}),
2f6253 16     };
17   }
18   return ret;
19 }