2023-02-22 01:29:05 -05:00
|
|
|
import type { ProxyOptions } from 'vite'
|
|
|
|
|
|
|
|
export function createViteProxy(isOpenProxy: boolean, viteEnv: ImportMetaEnv) {
|
|
|
|
if (!isOpenProxy)
|
|
|
|
return
|
|
|
|
|
|
|
|
const proxy: Record<string, string | ProxyOptions> = {
|
|
|
|
'/api': {
|
2023-02-24 02:03:49 -05:00
|
|
|
target: viteEnv.VITE_APP_API_BASE_URL,
|
2023-02-22 01:29:05 -05:00
|
|
|
changeOrigin: true,
|
2023-02-24 02:03:49 -05:00
|
|
|
rewrite: path => path.replace('/api/', '/'),
|
2023-02-22 01:29:05 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return proxy
|
|
|
|
}
|