Check method and path are defined in middleware

This commit is contained in:
Daniel Lugo 2021-10-10 15:45:05 -04:00
parent ce6a10f77f
commit 2de8e7a33a

View file

@ -356,7 +356,21 @@ module.exports = async (
}) })
app.use(async (req, res, next) => { 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() next()
} else { } else {
try { try {