From fe991ae2f75077949a91b3113f8c7080c12f74d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl?= Date: Sun, 9 Jun 2024 14:30:12 +0200 Subject: [PATCH] Update file.routes.js --- routes/file.routes.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/routes/file.routes.js b/routes/file.routes.js index fe3044a..8893c0d 100644 --- a/routes/file.routes.js +++ b/routes/file.routes.js @@ -3,8 +3,11 @@ const { uploadFile, getFile } = require("../controllers/file.controller"); const router = express.Router(); +const apiKeys = process.env.API_KEYS.split(","); +const allowPublicUploads = process.env.ALLOW_PUBLIC; + const authenticate = (req, res, next) => { - const apiKey = req.headers["x-api-key"]; + const apiKey = req.headers["x-api-key"] || req.query.api; if (!apiKey || !apiKeys.includes(apiKey)) { if (allowPublicUploads) { req.isPublicUpload = true;