mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-23 23:39:47 +08:00
refactor(projects): 细节优化
This commit is contained in:
@ -1,21 +1,18 @@
|
||||
import type { ProxyOptions } from 'vite';
|
||||
import { getEnvConfig } from '../../.env-config';
|
||||
|
||||
/**
|
||||
* 设置网络代理
|
||||
* @param viteEnv - vite环境描述
|
||||
* @param isOpenProxy - 是否开启代理
|
||||
* @param envConfig - env环境配置
|
||||
*/
|
||||
export function createViteProxy(viteEnv: ImportMetaEnv) {
|
||||
const isOpenProxy = viteEnv.VITE_HTTP_PROXY === 'true';
|
||||
export function createViteProxy(isOpenProxy: boolean, envConfig: EnvConfig) {
|
||||
if (!isOpenProxy) return undefined;
|
||||
|
||||
const { http } = getEnvConfig(viteEnv);
|
||||
|
||||
const proxy: Record<string, string | ProxyOptions> = {
|
||||
[http.proxy]: {
|
||||
target: http.url,
|
||||
[envConfig.proxy]: {
|
||||
target: envConfig.url,
|
||||
changeOrigin: true,
|
||||
rewrite: path => path.replace(new RegExp(`^${http.proxy}`), '')
|
||||
rewrite: path => path.replace(new RegExp(`^${envConfig.proxy}`), '')
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user