From 5c83557d2111971948eab6e73d6445260edb21c7 Mon Sep 17 00:00:00 2001 From: "Max P." Date: Sun, 11 May 2025 09:54:24 +0200 Subject: [PATCH] feat(auth): add verbose logging for API key extraction - Improve debugging by logging the provided and extracted API keys when verbose mode is enabled in the environment configuration. --- src/ltProxyAuth.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ltProxyAuth.ts b/src/ltProxyAuth.ts index b4b0340..bea1631 100644 --- a/src/ltProxyAuth.ts +++ b/src/ltProxyAuth.ts @@ -8,9 +8,17 @@ import { Env } from './env.ts'; export const authMiddleware: Middleware = async (ctx, next) => { const key = ctx.query.apiKey; + if (Env.verbose) { + console.debug('API key:', key); + } + // Support both ?apiKey=... and form body with apiKey=... const extractedKey = Array.isArray(key) ? key[0] : key; + if (Env.verbose) { + console.debug('Extracted API key:', extractedKey); + } + if (!extractedKey || !Env.apiKeys.includes(extractedKey)) { return new Response('Forbidden – Invalid API key', { status: 403 }); }