type ProxyItem = [string, string]; type ProxyList = ProxyItem[]; const regExp = (value: string, reg: string): string => { return value.replace(new RegExp(reg, "g"), ""); }; /** * * @param list * @returns ProxyList */ export function createProxy(list: ProxyList) { const proxy = {}; for (const [prefix, target] of list) { proxy[prefix] = { target: target, changeOrigin: true, rewrite: (path: string) => regExp(path, prefix), }; } return proxy; }