fix(chat): add SSE padding to bypass proxy buffering
This commit is contained in:
@@ -33,10 +33,18 @@ function startSse(res: Response) {
|
||||
// toplu halde göndermesini önlemek için.
|
||||
res.setHeader('X-Accel-Buffering', 'no');
|
||||
(res as any).flushHeaders?.();
|
||||
// Cloudflare gibi proxy'lerin buffer'ını aşmak için ~2KB dummy padding gönder.
|
||||
res.write(`: ${' '.repeat(2048)}\n\n`);
|
||||
if (typeof (res as any).flush === 'function') {
|
||||
(res as any).flush();
|
||||
}
|
||||
}
|
||||
|
||||
function sseWrite(res: Response, payload: Record<string, unknown>) {
|
||||
res.write(`data: ${JSON.stringify(payload)}\n\n`);
|
||||
if (typeof (res as any).flush === 'function') {
|
||||
(res as any).flush();
|
||||
}
|
||||
}
|
||||
|
||||
interface ChatAttachment { filename: string; text: string; }
|
||||
|
||||
Reference in New Issue
Block a user