From aa64f3237843cab292c843ac0471033934863b85 Mon Sep 17 00:00:00 2001 From: Agusti Fernandez Pardo Date: Thu, 23 Jun 2022 23:20:07 +0200 Subject: [PATCH] fix set headers error by adding missing return --- lib/helpers/verifyApiKey.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/helpers/verifyApiKey.ts b/lib/helpers/verifyApiKey.ts index 3ee1fad862..4a375aee26 100644 --- a/lib/helpers/verifyApiKey.ts +++ b/lib/helpers/verifyApiKey.ts @@ -16,7 +16,10 @@ export const dateNotInPast = function (date: Date) { export const verifyApiKey: NextMiddleware = async (req, res, next) => { const { prisma, userId, isAdmin } = req; // If the user is an admin and using a license key (from customPrisma), skip the apiKey check. - if (userId === 0 && isAdmin) await next(); + if (userId === 0 && isAdmin) { + await next(); + return; + } // Check if the apiKey query param is provided. if (!req.query.apiKey) return res.status(401).json({ message: "No apiKey provided" }); // remove the prefix from the user provided api_key. If no env set default to "cal_"