Fred Liang
2023-12-25 04:07:35 +08:00
parent c0ce70ccc7
commit 5af68ac545
2 changed files with 18 additions and 8 deletions

View File

@@ -39,9 +39,22 @@ async function handle(
10 * 60 * 1000,
);
const authResult = auth(req);
if (authResult.error) {
return NextResponse.json(authResult, {
status: 401,
});
}
const bearToken = req.headers.get("Authorization") ?? "";
const token = bearToken.trim().replaceAll("Bearer ", "").trim();
console.log(
bearToken,
serverConfig.googleApiKey,
token ? token : serverConfig.googleApiKey,
);
const key = token ? token : serverConfig.googleApiKey;
if (!key) {
return NextResponse.json(