lazy load HTTP script inside HTTPS website

1,082 views
Skip to first unread message

Jake K.

unread,
Jun 24, 2015, 8:27:47 PM6/24/15
to ang...@googlegroups.com

Hello,


I am trying to load Baidu map in my website which has HTTPS protocol. However I get the following error:


Mixed Content: The page at 'https://my-website.com' was loaded over HTTPS, but requested an insecure script'http://api.map.baidu.com/api?v=2.0&ak=shT00fgF7SPmpGg75s8gWv90&callback=initialize&_=1435191036739'. This request has been blocked; the content must be served over HTTPS


I tried to load Baidu with HTTPS protocol but it doesn't work.


How can I load Baidu inside a HTTPS website?, or more generally, how can I load a script with HTTP inside a HTTPS website?


Thank you

Sander Elias

unread,
Jun 25, 2015, 11:47:49 AM6/25/15
to ang...@googlegroups.com
Hi Jake,

You can't.  Not without the user being warned. It is a pretty big security issue if you do something like that, and actually voiding your HTTPS connection. 
If you really need to use things that  are not provided over HTTPS, switch your app back to HTTP. 



Regards
Sander

Rob R

unread,
Jun 28, 2015, 9:22:57 AM6/28/15
to ang...@googlegroups.com
Have you tried //api.map.baidu.com... instead of http://api.map.baidu.com ?

Jake K.

unread,
Jun 28, 2015, 2:05:33 PM6/28/15
to ang...@googlegroups.com
Hey, Rob

Yes, I had tried // instead of http:// for the baidu map.

However I found that for baidu map to work in HTTPS a different script should be loaded:

https://sapi.map.baidu.com (instead of http://api.map.baidu.com); notice the 'sapi.api' instead of api.map.

This was in the official Baidu documentation, however I did not explore the documentation too much since it is written in Chinese and the google translations do not always make sense.

Thanks for your support







--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/mkN2-nuMSfY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.



--

Jake K.

unread,
Aug 6, 2015, 2:21:08 AM8/6/15
to ang...@googlegroups.com
To the Angular team developers,

I have the following issue regarding $http POST request in IE9:


I am trying to make a post request using angularjs $http. The implementation looks something like this:

Assume $scope.user is an object that has been initialized like this:

$scope.user = {};
$scope.user.username = 'my-user-name';
$scope.user.password = 'my-password';

then, when hitting the 'Submit button' this script should execute:

$http({
    method: 'POST',
    url: 'url-to-api',
    headers: {
        'Content-Type':'application/x-www-form-urlencoded',
        'Access-Control-Allow-Origin':'*'
    },
    //-- this section produces the same output as 
    //-- angular.element.param( object ) 
    //transformRequest: function(obj) {
    //    var str = [];
    //    for(var p in obj)
    //        str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
    //    return str.join("&");
    //},
    //data: $scope.user                
    data: angular.element.param($scope.user)
});

--------------------------------------------------------------

The above code works in IE 10 and above. More details of the POST request can be seen in the attached edge.PNG file (the http post request in question is highlighted in yellow).

However in IE 9 it doesn't work. The $http POST request error callback is called right away, as if the request didn't go at all (in fact it is not captured by the IE console window). For more details please checkout the files ie.PNG and ie-error.PNG

PS: the calls are cross-domain, but even if I put the 'withCredentials: true' in the POST request it still doesn't work.

Thanks in advance!!

Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages