Skip to content

Commit

Permalink
Merge pull request #145 from Yanyutin753/key
Browse files Browse the repository at this point in the history
⭐ Fix preferentially using mjpApiKey
  • Loading branch information
Licoy authored Aug 15, 2024
2 parents aaa95c2 + 326dc03 commit 2b0f867
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/api/mj/[...path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 2b0f867

Please sign in to comment.