-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
49 lines (47 loc) · 1.63 KB
/
Copy pathvite.config.js
File metadata and controls
49 lines (47 loc) · 1.63 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
38
39
40
41
42
43
44
45
46
47
48
49
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const openaiKey = env.OPENAI_API_KEY || env.VITE_OPENAI_API_KEY || ''
const openaiProject = env.OPENAI_PROJECT_ID || env.VITE_OPENAI_PROJECT_ID || ''
const openaiHeaders = openaiKey ? { Authorization: `Bearer ${openaiKey}` } : {}
return {
plugins: [react()],
base: '/',
server: {
proxy: {
'/api': {
target: 'https://identity.smt.tfnsolutions.us',
changeOrigin: true,
secure: false
},
'/memo-api': {
target: 'https://memo.smt.tfnsolutions.us/api/v1',
changeOrigin: true,
secure: false,
rewrite: (path) => path.replace(/^\/memo-api/, '')
},
'/settings-api': {
target: 'https://setting.smt.tfnsolutions.us/api/v1',
changeOrigin: true,
secure: false,
rewrite: (path) => path.replace(/^\/settings-api/, '')
},
'/openai': {
target: 'https://api.openai.com',
changeOrigin: true,
secure: true,
headers: openaiHeaders,
rewrite: (path) => path.replace(/^\/openai/, ''),
configure: (proxy) => {
proxy.on('proxyReq', (proxyReq) => {
if (openaiKey) proxyReq.setHeader('Authorization', `Bearer ${openaiKey}`)
if (openaiProject) proxyReq.setHeader('OpenAI-Project', openaiProject)
proxyReq.setHeader('Content-Type', 'application/json')
})
}
}
}
}
}
})