Allow api key query fallback
ci / test (push) Successful in 11s

This commit is contained in:
Luna
2026-07-16 20:32:35 +00:00
parent 9905d0f496
commit 0ccd4e47ae
3 changed files with 33 additions and 36 deletions
+3 -6
View File
@@ -42,8 +42,9 @@ export function createApp(config: RuntimeConfig, deps: AppDependencies) {
const headerKey = req.header("x-api-key");
const bearer = req.header("authorization")?.replace(/^Bearer\s+/i, "").trim();
const queryKey = readOptionalString(req.query.api_key);
if (headerKey === config.apiKey || bearer === config.apiKey) {
if (headerKey === config.apiKey || bearer === config.apiKey || queryKey === config.apiKey) {
next();
return;
}
@@ -71,11 +72,7 @@ export function createApp(config: RuntimeConfig, deps: AppDependencies) {
}
function readCountRequest(req: Request): CountRequest {
const repo = typeof req.query.repo === "string"
? req.query.repo.trim()
: typeof req.query.query === "string"
? req.query.query.trim()
: "";
const repo = typeof req.query.repo === "string" ? req.query.repo.trim() : "";
if (!repo) {
throw new HttpError(400, "Missing repo query parameter");
}