From 13b6a3d7b8a50b6fbccc1947628ef254a53e2463 Mon Sep 17 00:00:00 2001 From: nai-degen Date: Tue, 23 May 2023 11:57:14 -0500 Subject: [PATCH] adds header to improve nginx compatibility --- src/proxy/middleware/response/handle-streamed-response.ts | 1 + src/proxy/queue.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/proxy/middleware/response/handle-streamed-response.ts b/src/proxy/middleware/response/handle-streamed-response.ts index 290b5d9..a9431ca 100644 --- a/src/proxy/middleware/response/handle-streamed-response.ts +++ b/src/proxy/middleware/response/handle-streamed-response.ts @@ -48,6 +48,7 @@ export const handleStreamedResponse: RawResponseBodyHandler = async ( res.setHeader("Content-Type", "text/event-stream"); res.setHeader("Cache-Control", "no-cache"); res.setHeader("Connection", "keep-alive"); + res.setHeader("X-Accel-Buffering", "no"); copyHeaders(proxyRes, res); res.flushHeaders(); } diff --git a/src/proxy/queue.ts b/src/proxy/queue.ts index 86104c0..6bd288f 100644 --- a/src/proxy/queue.ts +++ b/src/proxy/queue.ts @@ -299,6 +299,7 @@ function initStreaming(req: Request) { res.setHeader("Content-Type", "text/event-stream"); res.setHeader("Cache-Control", "no-cache"); res.setHeader("Connection", "keep-alive"); + res.setHeader("X-Accel-Buffering", "no"); // nginx-specific fix res.flushHeaders(); res.write("\n"); res.write(": joining queue\n\n");