CORS request and web::http::methods::OPTIONS is not firing in httpListener

Jul 2, 2015 at 5:37 PM
Hi guys,
To start with, very well done for all this! Casablanca is great!

I am trying to consume a REST service via a http POST using jQuery, in a cross domain manner; same domain but different TCP ports.
The first xhr to fire is the HTTP OPTIONS one towards the service endpoint, i.e. the httpListener.

Although I have
m_theListener->support(web::http::methods::OPTIONS, std::function.... );
my handlers is not being called and the REST server responnds with a 400.

Any ideas why?

Unless I got this wrong from the beginning, I need to hook for the OPTIONS request and respond accordingly (to Chrome) whether it can POST or not.
NB I am trying to cross-domain POST, some JSON data.

Many thanks,
Sterge
Jul 2, 2015 at 7:47 PM
Hi sterge,

Could you check using wireshark or fiddler and ensure that the right HTTP requests are being sent?

Next, could you post a larger snippet of your code, including the construction of the http_listener?

Thanks,
roschuma
Jul 3, 2015 at 8:10 AM
Hi Roschuma,

Thanks for your response!

I've sorted it at the end: it was the fact that I was not running the server application as Admin on Windows and thus it could not accept connections at port 9000.
Having said that, GET requests were working all along!

I now trap and log all the exceptions, instead of suppressing them. That's how I found out.
Many thanks,
Sterge