coderadar icon indicating copy to clipboard operation
coderadar copied to clipboard

Support for requests with HTTP-method "OPTIONS"

Open pschild opened this issue 8 years ago • 4 comments

Before a POST request can be sent, a "preflight" request in form of a OPTIONS request is made. So the API should allow OPTIONS requests as well. Otherwise the original POST request fails. See https://www.html5rocks.com/en/tutorials/cors/ for reference.

pschild avatar Nov 30 '16 20:11 pschild

Also see https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS:

Additionally, for HTTP request methods that can cause side-effects on server's data (in particular, for HTTP methods other than GET, or for POST usage with certain MIME types), the specification mandates that browsers "preflight" the request, soliciting supported methods from the server with an HTTP OPTIONS request method, and then, upon "approval" from the server, sending the actual request with the actual HTTP request method.

and https://spring.io/understanding/CORS#pre-flight-requests:

The preflight request is essentially asking the server if it would allow the DELETE request, without actually sending the DELETE request.

pschild avatar Feb 08 '17 21:02 pschild

Workaround is to create a WebConfig to allow CORS explicitly in org.wickedsource.coderadar.security package. See the attached file: WebConfig.java.txt

pschild avatar Feb 08 '17 21:02 pschild

When I activate the CORS config from your example, I get 403 Errors when issuing an OPTIONS request. Let's talk about this some more, so I understand it correctly.

thombergs avatar Feb 12 '17 15:02 thombergs

Is that still a thing?

trzpiot avatar Mar 06 '19 14:03 trzpiot