This commit is contained in:
2025-04-11 18:58:56 +08:00
commit 07e9aa3d52
438 changed files with 35686 additions and 0 deletions

21
build/vite/proxy.js Normal file
View File

@@ -0,0 +1,21 @@
const httpsRE = /^https:\/\//;
/**
* Generate proxy
* @param list
*/
export function createProxy(list = []) {
const ret = {};
for (const [prefix, target] of list) {
const isHttps = httpsRE.test(target);
// https://github.com/http-party/node-http-proxy#options
ret[prefix] = {
target: target,
changeOrigin: true,
ws: true,
rewrite: (path) => path.replace(new RegExp(`^${prefix}`), ''),
// https is require secure=false
...(isHttps ? { secure: false } : {}),
};
}
return ret;
}