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" }); } };