From c538ee94e93b672cebc55aa0f70ea088d41cdba1 Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Wed, 18 Sep 2024 16:15:52 +0100 Subject: [PATCH] Bugfix/Add header to allow sse on nginx (#3214) add header to allow sse on nginx --- packages/server/src/controllers/internal-predictions/index.ts | 1 + packages/server/src/controllers/predictions/index.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/server/src/controllers/internal-predictions/index.ts b/packages/server/src/controllers/internal-predictions/index.ts index 6539d76e0e7..b251eecb610 100644 --- a/packages/server/src/controllers/internal-predictions/index.ts +++ b/packages/server/src/controllers/internal-predictions/index.ts @@ -27,6 +27,7 @@ const createAndStreamInternalPrediction = async (req: Request, res: Response, ne 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 config: https://serverfault.com/a/801629 res.flushHeaders() const apiResponse = await utilBuildChatflow(req, true) diff --git a/packages/server/src/controllers/predictions/index.ts b/packages/server/src/controllers/predictions/index.ts index ae649b9bc81..504d6518aab 100644 --- a/packages/server/src/controllers/predictions/index.ts +++ b/packages/server/src/controllers/predictions/index.ts @@ -63,6 +63,7 @@ const createPrediction = async (req: Request, res: Response, next: NextFunction) 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 config: https://serverfault.com/a/801629 res.flushHeaders() const apiResponse = await predictionsServices.buildChatflow(req)