mercredi 18 février 2015

angularjs preflight request fails to load data

I am developing a single page application using Angularjs framework. inside my homeController i use a service call as below



$http({
method: 'POST',
url: 'http://localhost:1530/api/Profile?username=sa&password=da',
data: { Email: "dmytest@test.com", Password: "saas" },
headers: {'Content-Type': 'application/json'}
}).success();


The problem is that when i am making a api call the browser initiates a preflight request with method options instead of post. Server responds with all required headers.But the actual call is not done.Preflight request initiates only when using "Content-Type:application/json". I am posting Json data to server. Is there any way to either prevent the preflight request nor making a successfull api call?


It is working fine on mobile as well as on ajax call. Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire