-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.js
More file actions
37 lines (35 loc) · 1.06 KB
/
vite.config.js
File metadata and controls
37 lines (35 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
// Load env file based on `mode` in the current working directory.
// Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
const env = loadEnv(mode, process.cwd(), '')
return {
plugins: [vue()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
define: {
'process.env': env
},
server: {
proxy: {
'/chat/completions': {
target: env.AI_PROXY_TARGET_BASE_URL || 'https://aigc.sankuai.com/v1/openai/native',
changeOrigin: true,
configure: (proxy, options) => {
proxy.on('proxyReq', (proxyReq, req, res) => {
// 添加认证头
proxyReq.setHeader('Authorization', `Bearer ${env.AI_PROXY_API_KEY}`);
proxyReq.setHeader('Content-Type', 'application/json');
});
}
}
}
}
}
})