35 lines
1010 B
TypeScript
35 lines
1010 B
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
server: {
|
|
port: 3001,
|
|
proxy: {
|
|
// SSE events endpoint — must disable buffering for streaming
|
|
'/api/{{SERVICE_NAME}}/events': {
|
|
target: 'http://localhost:{{SERVICE_PORT}}',
|
|
changeOrigin: true,
|
|
// Disable response buffering so SSE events stream immediately
|
|
configure: (proxy) => {
|
|
proxy.on('proxyRes', (proxyRes) => {
|
|
// Prevent Vite from buffering SSE responses
|
|
if (proxyRes.headers['content-type']?.includes('text/event-stream')) {
|
|
proxyRes.headers['cache-control'] = 'no-cache';
|
|
proxyRes.headers['x-accel-buffering'] = 'no';
|
|
}
|
|
});
|
|
},
|
|
},
|
|
'/api': {
|
|
target: 'http://localhost:{{SERVICE_PORT}}',
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
preview: {
|
|
port: 3001,
|
|
},
|
|
});
|