From bf8426952079e9a116ad0e273c73612f0fa00e77 Mon Sep 17 00:00:00 2001 From: akira-cn Date: Fri, 10 Nov 2023 20:38:53 +0800 Subject: [PATCH 1/5] fix: remove the content-encoding header --- app/api/common.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/api/common.ts b/app/api/common.ts index adec611b2..e95bb4836 100644 --- a/app/api/common.ts +++ b/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, From dd6e79922a455862d6ae5c0a9469680d5c9e1d90 Mon Sep 17 00:00:00 2001 From: akira-cn Date: Fri, 10 Nov 2023 20:42:12 +0800 Subject: [PATCH 2/5] fix: remove the content-encoding header --- app/api/common.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/common.ts b/app/api/common.ts index e95bb4836..9f786c403 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -108,8 +108,8 @@ export async function requestOpenai(req: NextRequest) { // 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 + // Because Vercel uses gzip to compress the response, if we don't remove the content-encoding header + // The browser will try to decode the response with brotli and fail newHeaders.delete("content-encoding"); return new Response(res.body, { From 24d7dc9bf91f1f0513dd831a2ea7e60fc2612515 Mon Sep 17 00:00:00 2001 From: Rocky <40670362@qq.com> Date: Mon, 18 Dec 2023 20:34:37 +0800 Subject: [PATCH 3/5] Update api.ts to set proper header "Accept" So it can work fine for some GPT forward service. --- app/client/api.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/app/client/api.ts b/app/client/api.ts index eedd2c9ab..9f2a4b4e9 100644 --- a/app/client/api.ts +++ b/app/client/api.ts @@ -130,6 +130,7 @@ export function getHeaders() { const headers: Record = { "Content-Type": "application/json", "x-requested-with": "XMLHttpRequest", + "Accept": "application/json", }; const isAzure = accessStore.provider === ServiceProvider.Azure; From 0b814eff83308e899c5c5e915968abace263840c Mon Sep 17 00:00:00 2001 From: ChatGPTNextWeb <153288546+ChatGPTNextWeb@users.noreply.github.com> Date: Tue, 26 Dec 2023 12:47:25 +0800 Subject: [PATCH 4/5] Update Web App link in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 55061759b..83aba6974 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ One-Click to get a well-designed cross-platform ChatGPT web UI, with GPT3, GPT4 [![MacOS][MacOS-image]][download-url] [![Linux][Linux-image]][download-url] -[Web App](https://chat-gpt-next-web.vercel.app/) / [Desktop App](https://github.com/Yidadaa/ChatGPT-Next-Web/releases) / [Discord](https://discord.gg/YCkeafCafC) / [Twitter](https://twitter.com/mortiest_ricky) / [Buy Me a Coffee](https://www.buymeacoffee.com/yidadaa) +[Web App](https://app.nextchat.dev/) / [Desktop App](https://github.com/Yidadaa/ChatGPT-Next-Web/releases) / [Discord](https://discord.gg/YCkeafCafC) / [Twitter](https://twitter.com/mortiest_ricky) / [Buy Me a Coffee](https://www.buymeacoffee.com/yidadaa) [网页版](https://chatgpt.nextweb.fun/) / [客户端](https://github.com/Yidadaa/ChatGPT-Next-Web/releases) / [反馈](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) / [QQ 群](https://github.com/Yidadaa/ChatGPT-Next-Web/discussions/1724) / [打赏开发者](https://user-images.githubusercontent.com/16968934/227772541-5bcd52d8-61b7-488c-a203-0330d8006e2b.jpg) From bb3cc2c821c5584fa37d372b4e4830d9b61e8d55 Mon Sep 17 00:00:00 2001 From: ChatGPTNextWeb <153288546+ChatGPTNextWeb@users.noreply.github.com> Date: Tue, 26 Dec 2023 12:49:11 +0800 Subject: [PATCH 5/5] Update CN web app link in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 83aba6974..69b649926 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ One-Click to get a well-designed cross-platform ChatGPT web UI, with GPT3, GPT4 [Web App](https://app.nextchat.dev/) / [Desktop App](https://github.com/Yidadaa/ChatGPT-Next-Web/releases) / [Discord](https://discord.gg/YCkeafCafC) / [Twitter](https://twitter.com/mortiest_ricky) / [Buy Me a Coffee](https://www.buymeacoffee.com/yidadaa) -[网页版](https://chatgpt.nextweb.fun/) / [客户端](https://github.com/Yidadaa/ChatGPT-Next-Web/releases) / [反馈](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) / [QQ 群](https://github.com/Yidadaa/ChatGPT-Next-Web/discussions/1724) / [打赏开发者](https://user-images.githubusercontent.com/16968934/227772541-5bcd52d8-61b7-488c-a203-0330d8006e2b.jpg) +[网页版](https://app.nextchat.dev/) / [客户端](https://github.com/Yidadaa/ChatGPT-Next-Web/releases) / [反馈](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) / [QQ 群](https://github.com/Yidadaa/ChatGPT-Next-Web/discussions/1724) / [打赏开发者](https://user-images.githubusercontent.com/16968934/227772541-5bcd52d8-61b7-488c-a203-0330d8006e2b.jpg) [web-url]: https://chatgpt.nextweb.fun [download-url]: https://github.com/Yidadaa/ChatGPT-Next-Web/releases