简体   繁体   English

混合内容发行$ http.get AngularJS

[英]Mixed Content Issue $http.get AngularJS

I have an application running on HTTPS protocol. 我有一个运行在HTTPS协议上的应用程序。 I wrote an Angular function to get the data using $http service. 我编写了一个Angular函数,以使用$ http服务获取数据。

factory.loadImages = function(callback){

        $http.get("http://gainsight.0x10.info/api/image?page_no=0")
             .success(function(data){

                callback(data);

            }).error(function(status,error){

                console.log(status);

            });
    };

I am getting the below Mixed Content errors: 我收到以下混合内容错误:

Mixed Content: The page at 'https://www.hackerearth.com/gainsight-ui-development-hiring-challenge-1/problems/30146b3bf6954bba9752bd5599b3c8aa/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://gainsight.0x10.info/api/image?page_no=0'. This content should also be served over HTTPS.

Now i tried to change the http://gainsight.0x10.info/api/image?page_no=0 to https://gainsight.0x10.info/api/image?page_no=0 in my $http.get service which is unfortunately not available. 现在我尝试将$http.get服务中的http://gainsight.0x10.info/api/image?page_no=0更改为https://gainsight.0x10.info/api/image?page_no=0不幸的是不可用。

Any Help.. Much appreciated 任何帮助..万分感谢

Remove the protocol!! 删除协议!

Instead of using https://... just use //... . 而不是使用https://...而是使用//...

Hope it works :) 希望它能工作:)

Reference 参考

Even if you are able to call an http endpoint you will not be able to load the ressource because it is on a different domain and you have a cross domain issue (unless you fix that with jsonp or cors ) 即使您能够调用http终结点,您也将无法加载资源,因为它位于其他域上并且存在跨域问题(除非您使用jsonp或cors进行了修复)

http://www.d-mueller.de/blog/cross-domain-ajax-guide/ http://www.d-mueller.de/blog/cross-domain-ajax-guide/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM