瀏覽代碼

fix: remove the content-encoding header

akira-cn 2 年之前
父節點
當前提交
bf84269520
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      app/api/common.ts

+ 6 - 0
app/api/common.ts

@@ -106,6 +106,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,