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(