ruoyi-plus-soybean/build/config/proxy.ts

21 lines
513 B
TypeScript
Raw Normal View History

import type { ProxyOptions } from 'vite';
/**
*
2022-04-27 22:27:46 +08:00
* @param isOpenProxy -
* @param envConfig - env环境配置
*/
2022-04-27 22:27:46 +08:00
export function createViteProxy(isOpenProxy: boolean, envConfig: EnvConfig) {
if (!isOpenProxy) return undefined;
const proxy: Record<string, string | ProxyOptions> = {
2022-04-27 22:27:46 +08:00
[envConfig.proxy]: {
target: envConfig.url,
changeOrigin: true,
2022-04-27 22:27:46 +08:00
rewrite: path => path.replace(new RegExp(`^${envConfig.proxy}`), '')
}
};
return proxy;
}