Heroku error: page was loaded over HTTPS, but requested an insecure script 'angular-route.js'

青春壹個敷衍的年華 提交于 2020-01-05 04:31:11

问题


I've deployed my nodejs app to heroku. I have this file below as my index.html but somehow heroku is throwing me this error message to the chrome developer console (F12).

Error:

Mixed Content: The page at 'https://small-talkz.herokuapp.com/' was loaded over HTTPS, but requested an insecure script 'http://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular-route.js'. This request has been blocked; the content must be served over HTTPS.

index.html:

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
    $http.get('https://code.angularjs.org/1.4.9/angular.js').success(successCallback);
</script>
<script data-require="angular.js@1.4.x" src="https://code.angularjs.org/1.4.9/angular.js" data-semver="1.4.9">
</script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular-route.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.3.1/angular-ui-router.min.js"></script>
    <script src="/socket.io/socket.io.js"></script>
    <script src="script.js"></script>

    <link rel="stylesheet" type="text/css" href="../css/style.css">
</head>

<div ng-app="mymodule" ng-view>
</div>     
</html>

回答1:


Notice your CDN that's hosting angular-route does not have HTTPS in it - means it is not served in secure protocol.

Either host a copy of it on Heroku (naturally - HTTPS) or find a new CDN to work with.

Edit: as mentioned you can just replace http:// with https:// since Google's APIs can be served through https.



来源:https://stackoverflow.com/questions/38354473/heroku-error-page-was-loaded-over-https-but-requested-an-insecure-script-angu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!