vendredi 30 janvier 2015

ADAL - JavaScript used in Angular JS in SPA app , to call third party APIs exposed through APIGEE giving CORS error


I have created a SPA and used Azure AD for User store and ADAL-JavaScript library as mentioned on a http://ift.tt/1tNCMOM to integrate with my angular js code. It did authentication flow successfully, but when I was calling the third party API exposed using APIGEE, I was getting following error messages:


Failed to load resource: the server responded with a status of 502 (Bad Gateway)


XMLHttpRequest cannot load http: //webapiexposedusingapigee. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://mywebsite.in' is therefore not allowed access. The response had HTTP status code 502.


When I checked in Fiddler i got following fault string. "faultstring=Received 405 Response without Allow Header"


and warning as :


Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http:// http://ift.tt/1zgwh7e. This can be fixed by moving the resource to the same domain or enabling CORS.


I had added following headers on APIGEE:



<Header name="Access-Control-Allow-Origin">*</Header>
<Header name="Access-Control-Allow-Credentials">true</Header>
<Header name="Access-Control-Allow-Headers">Origin, X-Requested-With, Content-Type, Accept</Header>
<Header name="Access-Control-Max-Age">3628800</Header>
<Header name="Access-Control-Allow-Methods">GET, PUT, POST, DELETE, OPTION</Header>


Any help on this is appreciated.


Thanks.





Aucun commentaire:

Enregistrer un commentaire