From c0fbfbefbe492684d29abb0495d70495bf2227ff Mon Sep 17 00:00:00 2001 From: Marcel Laverdet Date: Fri, 22 Mar 2024 11:45:04 -0500 Subject: [PATCH] fix: undefined property in unmatched host --- lib/router.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/router.js b/lib/router.js index 0dae41e..ece7ac5 100644 --- a/lib/router.js +++ b/lib/router.js @@ -483,7 +483,7 @@ Router.prototype.allowedMethods = function (options = {}) { return next().then(function () { const allowed = {}; - if (!ctx.status || ctx.status === 404) { + if (ctx.matched && (!ctx.status || ctx.status === 404)) { for (let i = 0; i < ctx.matched.length; i++) { const route = ctx.matched[i]; for (let j = 0; j < route.methods.length; j++) {