fix: 手动打包 Proxy 问题(#91)

* perf: 检查代码

* feat: proxy setting

* chore: 调整为测试环境使用 `proxy`
This commit is contained in:
Redon
2023-02-22 14:29:05 +08:00
committed by GitHub
parent 66cecb6049
commit bf5c0cdf04
8 changed files with 28 additions and 16 deletions

1
config/index.ts Normal file
View File

@@ -0,0 +1 @@
export * from './proxy'

16
config/proxy.ts Normal file
View File

@@ -0,0 +1,16 @@
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
}