fix: API key authentication and REST handler errors (#446)

This commit is contained in:
Henry
2026-03-19 12:20:19 +00:00
committed by GitHub
parent 0b45ceff7f
commit 67cf523ee8
4 changed files with 18 additions and 14 deletions

View File

@@ -165,6 +165,13 @@ export function createPlugins(db: dbClient) {
: []),
apiKey({
enableSessionForAPIKeys: true,
customAPIKeyGetter: (ctx) => {
const authorization = ctx.headers?.get("authorization");
if (authorization?.startsWith("Bearer ")) {
return authorization.slice(7);
}
return ctx.headers?.get("x-api-key") ?? undefined;
},
rateLimit: {
enabled: true,
timeWindow: 1000 * 60, // 1 minute