adds header to improve nginx compatibility

This commit is contained in:
nai-degen 2023-05-23 11:57:14 -05:00
parent 03616f4bbc
commit 13b6a3d7b8
2 changed files with 2 additions and 0 deletions

View File

@ -48,6 +48,7 @@ export const handleStreamedResponse: RawResponseBodyHandler = async (
res.setHeader("Content-Type", "text/event-stream"); res.setHeader("Content-Type", "text/event-stream");
res.setHeader("Cache-Control", "no-cache"); res.setHeader("Cache-Control", "no-cache");
res.setHeader("Connection", "keep-alive"); res.setHeader("Connection", "keep-alive");
res.setHeader("X-Accel-Buffering", "no");
copyHeaders(proxyRes, res); copyHeaders(proxyRes, res);
res.flushHeaders(); res.flushHeaders();
} }

View File

@ -299,6 +299,7 @@ function initStreaming(req: Request) {
res.setHeader("Content-Type", "text/event-stream"); res.setHeader("Content-Type", "text/event-stream");
res.setHeader("Cache-Control", "no-cache"); res.setHeader("Cache-Control", "no-cache");
res.setHeader("Connection", "keep-alive"); res.setHeader("Connection", "keep-alive");
res.setHeader("X-Accel-Buffering", "no"); // nginx-specific fix
res.flushHeaders(); res.flushHeaders();
res.write("\n"); res.write("\n");
res.write(": joining queue\n\n"); res.write(": joining queue\n\n");