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++) {