seguimos habilitando la funcion realtime
This commit is contained in:
@@ -7,19 +7,23 @@ export function registerSse(app) {
|
||||
res.set({
|
||||
'Content-Type': 'text/event-stream',
|
||||
'Cache-Control': 'no-cache',
|
||||
Connection: 'keep-alive'
|
||||
'Connection': 'keep-alive'
|
||||
});
|
||||
res.flushHeaders();
|
||||
res.write(':\n\n');
|
||||
sseClients.push(res);
|
||||
|
||||
res.on('close', () => {
|
||||
res.flushHeaders();
|
||||
res.write('event: connected\ndata: {}\n\n'); // ← mantiene el stream vivo
|
||||
|
||||
sseClients.push(res);
|
||||
console.log(`🟢 Cliente SSE conectado (${sseClients.length})`);
|
||||
|
||||
req.on('close', () => {
|
||||
const idx = sseClients.indexOf(res);
|
||||
if (idx !== -1) sseClients.splice(idx, 1);
|
||||
res.end();
|
||||
console.log(`🔌 Cliente SSE desconectado (${sseClients.length})`);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
const broadcast = (data) => {
|
||||
const payload = `data: ${data}\n\n`;
|
||||
sseClients.forEach((client) => client.write(payload));
|
||||
|
||||
@@ -9,6 +9,19 @@ server {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
|
||||
location /events {
|
||||
proxy_pass http://planilla-api:4000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection '';
|
||||
chunked_transfer_encoding off;
|
||||
proxy_buffering off;
|
||||
proxy_cache off;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
}
|
||||
|
||||
|
||||
location /config.js {
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
add_header 'Content-Type' 'application/javascript';
|
||||
|
||||
Reference in New Issue
Block a user