add else if to api key request

pull/9078/head
Agusti Fernandez Pardo 2022-04-15 16:55:55 +02:00
parent e251fccb61
commit ca8ca913a8
1 changed files with 1 additions and 1 deletions

View File

@ -15,7 +15,7 @@ const today = new Date();
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" });
else 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);