0

This is my angularJs request:

url = root + "/products";
$http.post(url, params)
 .then(function(response) {
         console.log('Successfull...');
});

This is my server side headers in python tornado:

self.set_header("Access-Control-Allow-Origin", "*")
self.set_header("Access-Control-Allow-Headers", "x-requested-with")
self.set_header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")

And this is my option method:

def options(self, *args, **kwargs):
    self.set_status(204)
    self.finish()

Why angularJS sends only an option request and no post request?

ehsan shirzadi
  • 4,138
  • 12
  • 57
  • 99

1 Answers1

0

I belive your problem is related with this question

At the server side, my web method is adding 'Access-Control-Allow-Origin: *' to the HTTP response. I can see that responses do include this header now. My question is: How do I 'preflight' a request (OPTIONS)? I am using jQuery.getJSON to make the GET request but the browser cancels the request right away with the infamous:

When you make a http request related with CORS, request making a OPTION call first.

Suat Karabacak
  • 513
  • 1
  • 5
  • 21