This is more specific to HTTP in general, but I'm using Node.js as my platform.
What is the best approach when dealing with non accepted HTTP methods to my HTTP server? Currently, I support PUT and GET, but not POST. If a POST request is made, should I return a 403, or a 405?
If the HTTP method used is not acceptable, then according to the specification, you should return a 405 Method Not Allowed.
With 405, you must also include an Allow header specifying what HTTP methods are allowed. For example, Allow: POST
, or if there are multiple choices, Allow: POST, PUT
That would be "405 Method Not Allowed". Read all about it here: HTTP Status code definitions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With