mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-26 08:36:19 +08:00
wip: support vite
This commit is contained in:
@@ -1,16 +1,10 @@
|
||||
import type { ServerOptions } from 'http-proxy';
|
||||
|
||||
type ProxyItem = [string, string];
|
||||
|
||||
type ProxyList = ProxyItem[];
|
||||
|
||||
type ProxyTargetList = Record<
|
||||
string,
|
||||
{
|
||||
target: string;
|
||||
changeOrigin: boolean;
|
||||
rewrite: (path: string) => any;
|
||||
secure?: boolean;
|
||||
}
|
||||
>;
|
||||
type ProxyTargetList = Record<string, ServerOptions & { rewrite: (path: string) => string }>;
|
||||
|
||||
const httpsRE = /^https:\/\//;
|
||||
|
||||
@@ -23,9 +17,11 @@ export function createProxy(list: ProxyList = []) {
|
||||
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 } : {}),
|
||||
|
Reference in New Issue
Block a user