-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
40 lines (39 loc) · 1.5 KB
/
vite.config.js
File metadata and controls
40 lines (39 loc) · 1.5 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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
server: {
host: '0.0.0.0',
port: process.env.VITE_PORT ? parseInt(process.env.VITE_PORT) : 3072,
// Dynamically allow hosts from environment variable (for dev mode)
// ALLOWED_HOSTS can be a comma-separated list of hosts
// If HOST is set, it will be used as a single allowed host
// If neither is set, all hosts are allowed (useful behind trusted proxy)
allowedHosts: process.env.ALLOWED_HOSTS
? process.env.ALLOWED_HOSTS.split(',').map(h => h.trim()).filter(Boolean)
: process.env.HOST
? [process.env.HOST]
: undefined, // undefined means all hosts allowed
// Proxy API requests to backend server during development
proxy: {
'/api': {
target: `http://localhost:${process.env.BACKEND_PORT || 3073}`,
changeOrigin: true,
},
},
},
preview: {
host: '0.0.0.0',
port: 3072,
// Dynamically allow hosts from environment variable
// ALLOWED_HOSTS can be a comma-separated list of hosts
// If HOST is set, it will be used as a single allowed host
// If neither is set, all hosts are allowed (useful behind trusted proxy)
allowedHosts: process.env.ALLOWED_HOSTS
? process.env.ALLOWED_HOSTS.split(',').map(h => h.trim()).filter(Boolean)
: process.env.HOST
? [process.env.HOST]
: undefined, // undefined means all hosts allowed
},
})