B
B
BonBon Slick2017-10-27 17:34:54
JavaScript
BonBon Slick, 2017-10-27 17:34:54

This request has been blocked; the content must be served over HTTPS?

How to fix the error when Sokcet.io sends an attempt to connect to the server:

Mixed Content: The page at 'https://domain.com/ru' was loaded over HTTPS, 
but requested an insecure XMLHttpRequest endpoint 'http://localhost:3000/socket.io/?EIO=3&transport=polling&t=LzUGBey'. This request has been blocked; 
the content must be served over HTTPS.

Standard chat on sockets from the example at https://socket.io/
"use strict";
const express = require('express');
const app = express();
const path = require('path');
const server = require('http').createServer(app);
const io = require('socket.io')(server);
const port = process.env.PORT || 3000;

server.listen(port, function () {
    logTime('Server listening at port: ' + port);
});

....

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton Spirin, 2019-07-31
@Tyni4ek

Document.getElementsByClassName()
Read the first half of the first sentence in the link.
If you have one element, then you can fix it, for example, like this:
If multiple:

var items = document.getElementsByClassName('gLFyf gsfi');

Array.prototype.forEach.call(items, function(item) {
    item.value = '111';
});

V
Vladimir Mukovoz, 2017-10-27
@BonBonSlick

And again documentation
https://nginx.ru/ru/docs/http/websocket.html

B
Boris Korobkov, 2017-10-27
@BorisKorobkov

the content must be served over HTTPS

If I am unable to use a translator, I can translate:
the socket server should work not on http (port 80), but on https (port 443 + certificate)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question