1
When making a request DELETE
a url that does not support OPTIONS
browser returns me:
405 Method Not Allowed
Is there any way to prevent, in my Javascript code, the browser to send a pre-request OPTIONS
before sending a DELETE
?
1
When making a request DELETE
a url that does not support OPTIONS
browser returns me:
405 Method Not Allowed
Is there any way to prevent, in my Javascript code, the browser to send a pre-request OPTIONS
before sending a DELETE
?
2
No (*). When the browser is sending AJAX requests for a service, it will send all cookies related to the service domain. To protect the scenery where you navigate to http://site.malvado.com/
, and the site sends a DELETE (or POST, or PUT) to http://seu.banco.com/contas
, If the site uses a simple authentication mechanism based on the presence of a user cookie, then the site will delete your accounts. To prevent this type of attack, when a (modern) browser is sending requests to a domain other than the one on the page, it follows the cors protocol, that requires an OPTIONS request. If the server is aware of the possibility of these attacks (i.e., does not use a form of authentication that is vulnerable), then it will enable the CORS and will be able to respond to OPTIONS requests. If the service does not accept OPTIONS, then it is possible that it is not prepared to deal with the attacks of cross-Domain.
(*) However, there are situations where you want to go over this restriction. A few options:
Browser other questions tagged javascript jquery ajax http-request
You are not signed in. Login or sign up in order to post.
It doesn’t really accept OPTIONS. The interesting thing is that it doesn’t happen when I do POST. You could indicate me an extension(Chrome)?
– DaviAragao
I’m sorry, I don’t know any extensions. If the server supports POST, then it may be a version that is only configured to support GET and POST. If this is the case, and the server supports the X-HTTP-Method-Override, you can try using it to see if it works.
– carlosfigueira