chore: api request

This commit is contained in:
jialin
2024-06-10 21:14:37 +08:00
parent 6a60561401
commit f491b5dfb1
24 changed files with 685 additions and 312 deletions
+23
View File
@@ -0,0 +1,23 @@
const proxyTableList = ['cli', 'v1'];
// @ts-ingore
export default function createProxyTable(target?: string) {
const proxyTable = proxyTableList.reduce(
(obj: Record<string, object>, api) => {
const newTarget = target || 'http://localhost';
obj[`/${api}/`] = {
target: newTarget,
changeOrigin: true,
secure: false,
ws: true,
pathRewrite: (pth: string) => pth.replace(`/^/${api}/`, `/${api}`),
headers: {
origin: newTarget
}
};
return obj;
},
{}
);
return proxyTable;
}