2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-05 05:47:17 +08:00
Files
panel/web/build/config/proxy.ts
2024-10-10 00:17:04 +08:00

17 lines
523 B
Go

import type { ProxyOptions } from 'vite'
import { getProxyConfig } from '../../settings/proxy-config'
export function createViteProxy(isUseProxy = true, proxyType: ProxyType) {
if (!isUseProxy) return undefined
const proxyConfig = getProxyConfig(proxyType)
const proxy: Record<string, string | ProxyOptions> = {
[proxyConfig.prefix]: {
target: proxyConfig.target,
changeOrigin: true,
rewrite: (path: string) => path.replace(new RegExp(`^${proxyConfig.prefix}`), '')
}
}
return proxy
}