-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvite.config.ts
More file actions
33 lines (32 loc) · 961 Bytes
/
vite.config.ts
File metadata and controls
33 lines (32 loc) · 961 Bytes
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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
server: {
port: parseInt(process.env.VITE_PORT || '3000'),
strictPort: true,
hmr: {
overlay: true,
clientPort: parseInt(process.env.VITE_PORT || '3000')
},
proxy: {
'/api': {
target: `http://localhost:${process.env.PORT || '3001'}`,
changeOrigin: true,
configure: (proxy, options) => {
// Add retry logic for initial connection
proxy.on('error', (err: NodeJS.ErrnoException, req, res) => {
if (err.code === 'ECONNREFUSED') {
// Retry the request after a delay
setTimeout(() => {
console.log('Retrying proxy request to backend...');
proxy.web(req, res, options);
}, 1000);
}
});
}
}
}
}
})