From 09d8b48cccf332c9a063f9721857a715c56f380e Mon Sep 17 00:00:00 2001 From: Agusti Fernandez Pardo Date: Fri, 15 Apr 2022 16:46:50 +0200 Subject: [PATCH 1/2] make verifyApiKey not apply in docs --- lib/helpers/verifyApiKey.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/helpers/verifyApiKey.ts b/lib/helpers/verifyApiKey.ts index 6fe33c6ad3..998f783c77 100644 --- a/lib/helpers/verifyApiKey.ts +++ b/lib/helpers/verifyApiKey.ts @@ -13,11 +13,12 @@ const today = new Date(); // This verifies the API key and sets the user if it is valid. export const verifyApiKey: NextMiddleware = async (req, res, next) => { + const pathIsDocs = req.url?.startsWith("/docs"); + if (pathIsDocs) await next() if (!req.query.apiKey) res.status(401).json({ message: "No API key provided" }); const strippedApiKey = `${req.query.apiKey}`.replace(process.env.API_KEY_PREFIX || "cal_", ""); const hashedKey = hashAPIKey(strippedApiKey); - await prisma.apiKey .findUnique({ where: { hashedKey } }) .then(async (apiKey) => { From e251fccb61769d376a6c1db69df49d28a012b3ee Mon Sep 17 00:00:00 2001 From: Agusti Fernandez Pardo Date: Fri, 15 Apr 2022 16:47:08 +0200 Subject: [PATCH 2/2] make verifyApiKey not apply in docs --- lib/helpers/verifyApiKey.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/helpers/verifyApiKey.ts b/lib/helpers/verifyApiKey.ts index 998f783c77..653d8067ee 100644 --- a/lib/helpers/verifyApiKey.ts +++ b/lib/helpers/verifyApiKey.ts @@ -14,7 +14,7 @@ const today = new Date(); // This verifies the API key and sets the user if it is valid. export const verifyApiKey: NextMiddleware = async (req, res, next) => { const pathIsDocs = req.url?.startsWith("/docs"); - if (pathIsDocs) await next() + if (pathIsDocs) await next(); if (!req.query.apiKey) res.status(401).json({ message: "No API key provided" }); const strippedApiKey = `${req.query.apiKey}`.replace(process.env.API_KEY_PREFIX || "cal_", "");