Angularjs http request to external Azure App Api fails from Azure Web App with "https", but works when url is http. Authentication is turned on in Web App, but requires no action if not authenticated. What am I missing?
Asked
Active
Viewed 1,785 times
0
-
1I think you issue is `Same Origin Policy`: http://stackoverflow.com/a/4032123/2952074 – Benjamin Soulier Sep 07 '16 at 12:40
-
Thank you for letting me know about this. I will try this and let you know how it turns out. I also found this article, which is related to the posting that you've pointed out. http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api – rjespera Sep 07 '16 at 14:29
-
That did the trick. It was same origin policy. I matched the protocols "https" and it worked. Thanks @bsoulier – rjespera Sep 08 '16 at 03:22
-
@bsoulier it would be good to post your comment as an answer so that this question can be marked as answered. – Chris Gillum Sep 08 '16 at 17:13
-
@rjespera how have you resolved this issue, whether you have handled it from api side or webapp side. Sorry I am newbie with Azure cloud so can you please help out. – Mrunal Oct 06 '17 at 06:26
-
Yes, it's on the app side. I basically matched the protocol of the webapp I was in with the url of the resource 'web api' I was calling. So if you web app is https, the resource (web api) has to be https as well. – rjespera Oct 10 '17 at 18:50
2 Answers
0
@bsoulier lead me to the culprit. It was the Same Origin Policy, mistmatched protocol (web api url needed to be "https" as well) that was causing the problem.

rjespera
- 5
- 4
0
Your issue is about Same Origin Policy
, on which you can find detials on this SO answer.
To make long story short, you can't call a less secure resource than the page you are on (in your case making an AJAX request from an HTTPS page down to an HTTP resource).

Community
- 1
- 1

Benjamin Soulier
- 2,223
- 1
- 18
- 30