You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
372 B
TypeScript
17 lines
372 B
TypeScript
import type { ProxyOptions } from 'vite'
|
|
|
|
export function createViteProxy(isOpenProxy: boolean, viteEnv: ImportMetaEnv) {
|
|
if (!isOpenProxy)
|
|
return
|
|
|
|
const proxy: Record<string, string | ProxyOptions> = {
|
|
'/api': {
|
|
target: viteEnv.VITE_GLOB_API_URL,
|
|
changeOrigin: true,
|
|
rewrite: path => path.replace(/^\/api/, ''),
|
|
},
|
|
}
|
|
|
|
return proxy
|
|
}
|