File size: 638 Bytes
2be007a
4a5bfab
 
2be007a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a5bfab
 
 
2be007a
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
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd(), '')
  const backendUrl = env.VITE_BACKEND_URL || 'http://localhost:7860'
  const backendWsUrl = backendUrl.replace(/^http/, 'ws')

  return {
    plugins: [react()],
    server: {
      proxy: {
        '/api': {
          target: backendUrl,
          changeOrigin: true,
          secure: false,
        },
        '/ws': {
          target: backendWsUrl,
          ws: true,
          changeOrigin: true,
          secure: false,
        }
      }
    }
  }
})