我在Heroku上部署了this application 。当我在http上加载页面时,似乎工作正常,但是在使用https:
加载时出现问题Mixed Content: The page at '<URL>' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint '<URL>'. This request has been blocked; the content must be served over HTTPS.
应用程序的服务器端部分是使用Python制作的,前端部分包含一个Javascript文件和一个index.html文件。这就是JS的样子:
$(document).ready(function(){
//connect to the socket server.
var socket = io.connect('http://' + document.domain + ':' + location.port + '/test');
var numbers_received = [];
//receive details from server
socket.on('newnumber', function(msg) {
console.log("Received number" + msg.number);
//maintain a list of ten numbers
if (numbers_received.length >= 10){
numbers_received.shift()
}
numbers_received.push(msg.number);
numbers_string = '';
for (var i = 0; i < numbers_received.length; i++){
numbers_string = numbers_string + '<p>' + numbers_received[i].toString() + '</p>';
}
$('#log').html(numbers_string);
});
});
我尝试通过以下方式更改var socket = io.connect('http://' + document.domain + ':' + location.port + '/test');
:
var socket = io.connect('https://' + document.domain + ':' + location.port + '/test');
var socket = io.connect('/');
var socket = io.connect('https://link-of-my-heroku-app.com);
但是这些都不起作用,有什么建议吗?