From 2472e28f85499d4908782ef9d81c9e6a6c5bfbdb Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 3 Mar 2025 23:56:07 -0800 Subject: [PATCH] fix(api): make api key check case insensitive --- app/api/workflow/middleware.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/api/workflow/middleware.ts b/app/api/workflow/middleware.ts index 63c607528b..d744f5bddd 100644 --- a/app/api/workflow/middleware.ts +++ b/app/api/workflow/middleware.ts @@ -33,8 +33,14 @@ export async function validateWorkflowAccess( } // API key authentication - const apiKey = - request.headers.get('x-api-key') || request.nextUrl.searchParams.get('X-API-KEY') + let apiKey = null + for (const [key, value] of request.headers.entries()) { + if (key.toLowerCase() === 'x-api-key' && value) { + apiKey = value + break + } + } + if (!apiKey || !workflow.apiKey || apiKey !== workflow.apiKey) { return { error: {