From 19137b79bcf17d1b1be01740dd5ed0238c784680 Mon Sep 17 00:00:00 2001 From: Fred Liang Date: Mon, 25 Dec 2023 09:56:51 +0800 Subject: [PATCH 1/3] fix: return bearer header when using openai --- app/api/common.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/api/common.ts b/app/api/common.ts index 8e029c35b..a6f4c5721 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -9,9 +9,16 @@ const serverConfig = getServerSideConfig(); export async function requestOpenai(req: NextRequest) { const controller = new AbortController(); - const authValue = - req.headers.get("Authorization")?.trim().replaceAll("Bearer ", "").trim() ?? - ""; + if (serverConfig.isAzure) { + const authValue = + req.headers + .get("Authorization") + ?.trim() + .replaceAll("Bearer ", "") + .trim() ?? ""; + } else { + const authValue = req.headers.get("Authorization") ?? ""; + } const authHeaderName = serverConfig.isAzure ? "api-key" : "Authorization"; let path = `${req.nextUrl.pathname}${req.nextUrl.search}`.replaceAll( From 422d70d928fbd30f69789cd4f05bac4204dc6c8c Mon Sep 17 00:00:00 2001 From: Fred Liang Date: Mon, 25 Dec 2023 10:25:43 +0800 Subject: [PATCH 2/3] chore: update auth value logic (#3630) --- app/api/common.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/api/common.ts b/app/api/common.ts index a6f4c5721..2d89ea1e5 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -9,17 +9,21 @@ const serverConfig = getServerSideConfig(); export async function requestOpenai(req: NextRequest) { const controller = new AbortController(); + var authValue, + authHeaderName = ""; if (serverConfig.isAzure) { - const authValue = + authValue = req.headers .get("Authorization") ?.trim() .replaceAll("Bearer ", "") .trim() ?? ""; + + authHeaderName = "api-key"; } else { - const authValue = req.headers.get("Authorization") ?? ""; + authValue = req.headers.get("Authorization") ?? ""; + authHeaderName = "Authorization"; } - const authHeaderName = serverConfig.isAzure ? "api-key" : "Authorization"; let path = `${req.nextUrl.pathname}${req.nextUrl.search}`.replaceAll( "/api/openai/", From a91ac91977001a6ee68c360a810612b3b20ad896 Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Tue, 26 Dec 2023 02:44:40 +0700 Subject: [PATCH 3/3] Fix [UI/UX] [Emoji] emoji URL (#3647) --- app/components/emoji.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/components/emoji.tsx b/app/components/emoji.tsx index 616e80ed3..a2a50320d 100644 --- a/app/components/emoji.tsx +++ b/app/components/emoji.tsx @@ -10,7 +10,10 @@ import BotIcon from "../icons/bot.svg"; import BlackBotIcon from "../icons/black-bot.svg"; export function getEmojiUrl(unified: string, style: EmojiStyle) { - return `https://cdn.staticfile.org/emoji-datasource-apple/15.0.1/img/${style}/64/${unified}.png`; + // Whoever owns this Content Delivery Network (CDN), I am using your CDN to serve emojis + // Old CDN broken, so I had to switch to this one + // Author: https://github.com/H0llyW00dzZ + return `https://cdn.jsdelivr.net/npm/emoji-datasource-apple/img/${style}/64/${unified}.png`; } export function AvatarPicker(props: {