From 2de8e7a33a30913137e753233ff1be78ecb51cdd Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Sun, 10 Oct 2021 15:45:05 -0400 Subject: [PATCH] Check method and path are defined in middleware --- src/routes.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/routes.js b/src/routes.js index 78f020cd..f6b7bd3d 100644 --- a/src/routes.js +++ b/src/routes.js @@ -356,7 +356,21 @@ module.exports = async ( }) app.use(async (req, res, next) => { - if (unprotectedRoutes[req.method][req.path]) { + if (!req.method) { + logger.error( + 'No req.method in unprotected routes middleware.', + 'req.path:', + req.path + ) + next() + } else if (!req.path) { + logger.error( + 'No req.path in unprotected routes middleware.', + 'req.method:', + req.method + ) + next() + } else if (unprotectedRoutes[req.method][req.path]) { next() } else { try {