405 Method Not Allowed is returned when the server recognizes the request's HTTP method but does not allow it for the target resource — for example sending GET to an endpoint that only accepts POST.
By spec a 405 response must include an Allow header listing the methods the resource actually supports, so the client knows which method to retry with.
DELETE /api/articles HTTP/1.1
Host: api.example.comHTTP/1.1 405 Method Not Allowed
Allow: GET, POST
Content-Type: application/json
{"error":"method_not_allowed","allowed":["GET","POST"]}app.route('/api/articles')
.get(list)
.post(create)
.all((req, res) => res.set('Allow', 'GET, POST').sendStatus(405));location /api/articles {
limit_except GET POST { deny all; } # others -> 405
}