mardi 4 août 2015

Http request returns as failure but actually succeeds

I'm developing a web API and a website to interact with that api. So far I have each part done. I am using angular js for my website and an asp.net webapi for the other end. When I try to connect the two together to make it all work the signal sends and the api end gets executed like normal however in the console on the website end gives me an error: XMLHttpRequest cannot load http://localhost:1795/api/products/[ip address]/en-us/[product]/[version]/[email address]. A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:50028' is therefore not allowed access.

It just seems to be going in loops because if I now remove the custom header I provided for the Access-Control-Allow-Origin it still triggers the process I have in the api which gets executed as normal but I still end up getting an error on the other end. XMLHttpRequest cannot load http://localhost:1795/api/products/[ip address]/en-us/[product]/[version]/[email address]. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:50028' is therefore not allowed access.

If I remove the credentials from the http request I get a 401 unauthorized error and the api process won't trigger. I've created both of these projects in Visual Studio 2013 and are both running in Chrome.

Do I ignore the errors on the website side and keep things as they are? Or is there another way to make the call without getting these console errors?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire