From 03e2c6278de277da3d7c720f31e1f4200919df11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20L=C3=B3pez?= Date: Mon, 18 Nov 2024 17:18:53 -0700 Subject: [PATCH] fix: cron api key checks (#17730) --- packages/features/calendar-cache/api/cron.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/features/calendar-cache/api/cron.ts b/packages/features/calendar-cache/api/cron.ts index 2a8869779c..63faac20c6 100644 --- a/packages/features/calendar-cache/api/cron.ts +++ b/packages/features/calendar-cache/api/cron.ts @@ -7,8 +7,8 @@ import { SelectedCalendarRepository } from "@calcom/lib/server/repository/select import { CalendarCache } from "../calendar-cache"; const validateRequest = (req: NextApiRequest) => { - const apiKey = String(req.query.apiKey) || req.headers.authorization; - if (!apiKey || ![process.env.CRON_API_KEY, `Bearer ${process.env.CRON_SECRET}`].includes(apiKey)) { + const apiKey = req.headers.authorization || req.query.apiKey; + if (![process.env.CRON_API_KEY, `Bearer ${process.env.CRON_SECRET}`].includes(`${apiKey}`)) { throw new HttpError({ statusCode: 401, message: "Unauthorized" }); } };