Skip to content

Comments

Add opt-in 405 Method Not Allowed responses#191

Open
EduardoAC wants to merge 1 commit intopillarjs:masterfrom
EduardoAC:fix/405-method-not-allowed/issue-2414
Open

Add opt-in 405 Method Not Allowed responses#191
EduardoAC wants to merge 1 commit intopillarjs:masterfrom
EduardoAC:fix/405-method-not-allowed/issue-2414

Conversation

@EduardoAC
Copy link

Summary

  • Adds an opt-in methodNotAllowed Router option to return 405 Method Not Allowed when a route path matches but the HTTP method is unsupported.
  • Sets an Allow header based on matched route methods (includes HEAD when GET is supported via existing helpers).
  • Default behaviour remains unchanged (still falls through to 404 without the option).

Why

Addresses expressjs/express#2414 by providing a per-router configurable 405 response without breaking existing applications.

Tests

  • npx mocha --reporter spec --check-leaks test/

Collect Allow header from matched routes when enabled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant