From b6b7584f63f10023c5c0eec15dc74faca5ac76c4 Mon Sep 17 00:00:00 2001 From: Yifei Zhang Date: Wed, 27 Dec 2023 01:26:48 +0800 Subject: [PATCH 1/7] Merge pull request #3215 from akira-cn/main 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 5520e201d50..8d2a0ec9b5d 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -122,6 +122,12 @@ export async function requestOpenai(req: NextRequest) { newHeaders.delete("OpenAI-Organization"); } + // 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 + // 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, { status: res.status, statusText: res.statusText, From 0c9b44406edc79d21f7c496c1db6f0c2b73ee323 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 2/7] 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 17b10e18f98..4ccbb770e87 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://chatgpt.nextweb.fun/) / [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 57519d1f05f6abb7f734f7a2142b0cc05c6ed296 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 3/7] 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 4ccbb770e87..96cc3cc3664 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 From 552ccacf2850444807ea0411526beff290249c79 Mon Sep 17 00:00:00 2001 From: Yifei Zhang Date: Wed, 27 Dec 2023 01:24:44 +0800 Subject: [PATCH 4/7] Merge pull request #3570 from Rocky0102/main --- app/client/api.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/app/client/api.ts b/app/client/api.ts index e561390241e..88fa00e4049 100644 --- a/app/client/api.ts +++ b/app/client/api.ts @@ -145,6 +145,7 @@ export function getHeaders() { const headers: Record = { "Content-Type": "application/json", "x-requested-with": "XMLHttpRequest", + "Accept": "application/json", }; const modelConfig = useChatStore.getState().currentSession().mask.modelConfig; const isGoogle = modelConfig.model === "gemini-pro"; From 190681e411002a739f9bdb2dbda0f5a9f18a7774 Mon Sep 17 00:00:00 2001 From: Fred Liang Date: Mon, 25 Dec 2023 10:25:43 +0800 Subject: [PATCH 5/7] chore: update auth value logic (#3630) --- app/api/common.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/api/common.ts b/app/api/common.ts index 8d2a0ec9b5d..a5b3190a13b 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -9,8 +9,21 @@ const serverConfig = getServerSideConfig(); export async function requestOpenai(req: NextRequest) { const controller = new AbortController(); - const authValue = req.headers.get("Authorization") ?? ""; - const authHeaderName = serverConfig.isAzure ? "api-key" : "Authorization"; + var authValue, + authHeaderName = ""; + if (serverConfig.isAzure) { + authValue = + req.headers + .get("Authorization") + ?.trim() + .replaceAll("Bearer ", "") + .trim() ?? ""; + + authHeaderName = "api-key"; + } else { + authValue = req.headers.get("Authorization") ?? ""; + authHeaderName = "Authorization"; + } let path = `${req.nextUrl.pathname}${req.nextUrl.search}`.replaceAll( "/api/openai/", From 75f7438b221a575cc0ec7b628dd64be6019c2849 Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Wed, 27 Dec 2023 02:05:03 +0700 Subject: [PATCH 6/7] Fix [Api] [Common Server Side] Change variable - [+] fix(common.ts): change variable declaration from 'var' to 'let' for 'authValue' --- app/api/common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/common.ts b/app/api/common.ts index a5b3190a13b..5436e9a7766 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -9,7 +9,7 @@ const serverConfig = getServerSideConfig(); export async function requestOpenai(req: NextRequest) { const controller = new AbortController(); - var authValue, + let authValue, authHeaderName = ""; if (serverConfig.isAzure) { authValue = From 4123981866399fdfb6c7b9f3eb2bba4619d9c79b Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Wed, 27 Dec 2023 02:05:33 +0700 Subject: [PATCH 7/7] Fix Front End Issue about package - [+] chore(package.json): update "@tauri-apps/api" dependency to version 1.5.3 - [+] chore(yarn.lock): update "@tauri-apps/api" dependency to version 1.5.3 --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 6c650e61086..253fa504f58 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "@fortaine/fetch-event-source": "^3.0.6", "@hello-pangea/dnd": "^16.5.0", "@svgr/webpack": "^6.5.1", - "@tauri-apps/api": "^1.5.2", + "@tauri-apps/api": "^1.5.3", "@types/lodash": "^4.14.199", "@vercel/analytics": "^0.1.11", "emoji-picker-react": "^4.5.15", diff --git a/yarn.lock b/yarn.lock index e5186a0f85d..7536bc8e8dd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1344,10 +1344,10 @@ dependencies: tslib "^2.4.0" -"@tauri-apps/api@^1.5.2": - version "1.5.2" - resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.5.2.tgz#e92880d3435c8f46a7a152de226f014ec1f224b5" - integrity sha512-tZK3XJiIUnUdHN7rGqA+j57dvT3/7z2bEiPfWmO3uAymv2JMBJrfGwbyDWLjGue37UVhh0gLYSkA9wV+/bASwA== +"@tauri-apps/api@^1.5.3": + version "1.5.3" + resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.5.3.tgz#f7b362b1f30aadb0a8bbeb7ae111755c0ed33d73" + integrity sha512-zxnDjHHKjOsrIzZm6nO5Xapb/BxqUq1tc7cGkFXsFkGTsSWgCPH1D8mm0XS9weJY2OaR73I3k3S+b7eSzJDfqA== "@tauri-apps/cli-darwin-arm64@1.5.7": version "1.5.7" @@ -4099,7 +4099,7 @@ lodash.merge@^4.6.2: lodash@^4.17.21: version "4.17.21" - resolved "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== log-update@^4.0.0: