Skip to content

Commit 350ddd2

Browse files
authored
Merge pull request ChatGPTNextWeb#3215 from akira-cn/main
fix: remove the content-encoding header
2 parents c03abda + dd6e799 commit 350ddd2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

app/api/common.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ export async function requestOpenai(req: NextRequest) {
122122
// to disable nginx buffering
123123
newHeaders.set("X-Accel-Buffering", "no");
124124

125+
// The latest version of the OpenAI API forced the content-encoding to be "br" in json response
126+
// So if the streaming is disabled, we need to remove the content-encoding header
127+
// Because Vercel uses gzip to compress the response, if we don't remove the content-encoding header
128+
// The browser will try to decode the response with brotli and fail
129+
newHeaders.delete("content-encoding");
130+
125131
return new Response(res.body, {
126132
status: res.status,
127133
statusText: res.statusText,

0 commit comments

Comments
 (0)