From 326dc0370d4e5ad74c0b14b1b3985625da3545b3 Mon Sep 17 00:00:00 2001 From: Clivia <132346501+Yanyutin753@users.noreply.github.com> Date: Wed, 14 Aug 2024 22:42:20 +0800 Subject: [PATCH] =?UTF-8?q?=E2=AD=90=20Fix=20preferentially=20using=20mjpA?= =?UTF-8?q?piKey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mj/[...path]/route.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api/mj/[...path]/route.ts b/app/api/mj/[...path]/route.ts index cd5f225c..2a6a0e48 100644 --- a/app/api/mj/[...path]/route.ts +++ b/app/api/mj/[...path]/route.ts @@ -59,10 +59,10 @@ async function handle( }); } - const bearToken = req.headers.get("Authorization") ?? ""; - const token = bearToken.trim().replaceAll("Bearer ", "").trim(); + const bearToken = req.headers.get("Authorization")?.trim() ?? ""; + const token = bearToken.startsWith("Bearer ") ? bearToken.slice(7).trim() : bearToken; - const key = token ? token : serverConfig.mjpApiKey; + const key = serverConfig.mjpApiKey || token; if (!key) { return NextResponse.json(