swanwish / blog

My blog website
0 stars 0 forks source link

Angular 2 HTTP POST does an OPTIONS call #12

Open swanwish opened 7 years ago

swanwish commented 7 years ago

This issue is caused by CORS request.

The browser creates a pre-flight request with the OPTIONS verb in order to know if he can continue and make the "real" request.

Read more about CORS HTTP access control (CORS).

swanwish commented 7 years ago

Same answer from HTTP POST turns into OPTIONS

it looks like CORS request and it is a browser making the pre-flight OPTIONS request. There is a nice article on the topic: http://www.html5rocks.com/en/tutorials/cors/

I had a brief look at the discussion on the forum where it is suggested that this POST request should behave like simple GET but actually in your case there are more headers (and I suspect that you are sending JSON) so IMHO this is not so called "simple" CORS request.