diff --git a/app/api/common.ts b/app/api/common.ts index 9565a7a0a..0d269dfb5 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -126,6 +126,12 @@ export async function requestOpenai(req: NextRequest) { // to disable nginx buffering newHeaders.set("X-Accel-Buffering", "no"); + // The latest version of the OpenAI API forced the content-encoding to be "br" in json response + // So if the streaming is disabled, we need to remove the content-encoding header + // But vercel uses gzip to compress the response + // So we need to remove the content-encoding header + newHeaders.delete("content-encoding"); + return new Response(res.body, { status: res.status, statusText: res.statusText,