feat: add error handle

This commit is contained in:
vben
2020-10-18 21:55:21 +08:00
parent c0692b0f43
commit 7101587b96
32 changed files with 674 additions and 116 deletions

View File

@@ -2,13 +2,17 @@ type ProxyItem = [string, string];
type ProxyList = ProxyItem[];
const reg = /^https:\/\//;
export function createProxy(list: ProxyList = []) {
const ret: any = {};
for (const [prefix, target] of list) {
const isHttps = reg.test(target);
ret[prefix] = {
target: target,
changeOrigin: true,
rewrite: (path: string) => path.replace(new RegExp(`^${prefix}`), ''),
...(isHttps ? { secure: false } : {}),
};
}
return ret;