mirror of
https://github.com/fumiama/paper-manager.git
synced 2026-06-12 04:00:23 +08:00
optimize vben/build
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
/**
|
||||
* Used to parse the .env.development proxy configuration
|
||||
*/
|
||||
import type { ProxyOptions } from 'vite';
|
||||
import type { ProxyOptions } from 'vite'
|
||||
|
||||
type ProxyItem = [string, string];
|
||||
type ProxyItem = [string, string]
|
||||
|
||||
type ProxyList = ProxyItem[];
|
||||
type ProxyList = ProxyItem[]
|
||||
|
||||
type ProxyTargetList = Record<string, ProxyOptions>;
|
||||
type ProxyTargetList = Record<string, ProxyOptions>
|
||||
|
||||
const httpsRE = /^https:\/\//;
|
||||
const httpsRE = /^https:\/\//
|
||||
|
||||
/**
|
||||
* Generate proxy
|
||||
* @param list
|
||||
*/
|
||||
export function createProxy(list: ProxyList = []) {
|
||||
const ret: ProxyTargetList = {};
|
||||
const ret: ProxyTargetList = {}
|
||||
for (const [prefix, target] of list) {
|
||||
const isHttps = httpsRE.test(target);
|
||||
const isHttps = httpsRE.test(target)
|
||||
|
||||
// https://github.com/http-party/node-http-proxy#options
|
||||
ret[prefix] = {
|
||||
@@ -28,7 +28,7 @@ export function createProxy(list: ProxyList = []) {
|
||||
rewrite: (path) => path.replace(new RegExp(`^${prefix}`), ''),
|
||||
// https is require secure=false
|
||||
...(isHttps ? { secure: false } : {}),
|
||||
};
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return ret
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user