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

21 lines
550 B
TypeScript
Raw Normal View History

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