mirror of
https://github.com/Chanzhaoyu/chatgpt-web.git
synced 2025-07-21 11:57:47 +00:00
fix: 手动打包 Proxy 问题(#91)
* perf: 检查代码 * feat: proxy setting * chore: 调整为测试环境使用 `proxy`
This commit is contained in:
1
config/index.ts
Normal file
1
config/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './proxy'
|
16
config/proxy.ts
Normal file
16
config/proxy.ts
Normal 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
|
||||
}
|
Reference in New Issue
Block a user