Answer the question
In order to leave comments, you need to log in
How to solve the problem with Socket.io and Https?
I put the script of the roulette of things. There is a bunch of apache + nodejs + socket.io. If you go to the site by IP address, then the site connects to the bot via a socket, everything is fine in the console. If you go to the site by domain, then it swears with two errors:
GET https://site.ru:2053/socket.io/?EIO=3&transport=polling&t=1564049380135-11 521
Access to XMLHttpRequest at 'https://site.ru:2053/socket.io/?EIO=3&transport=polling&t=1564049380135-11' from origin 'https://site.ru' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
var socket = io.connect(':2053');
also tried to specify var socket = io.connect(https://site.ru':2053');
it, nothing helped. var auth = require('http-auth'),
scribe = require('scribe-js')(),
console = process.console,
config = require('./config.js'),
app = require('express')(),
server = require('https').Server(app),
io = require('socket.io')(https),
redis = require('redis'),
requestify = require('requestify'),
fs = require('fs'),
privateKey = fs.readFileSync('/var/www/bot/keys/privkey.pem'),
certificate = fs.readFileSync('/var/www/bot/keys/cert.pem'),
credentials = {key: privateKey, cert: certificate},
https = require('https').Server(credentials,app);
https.listen(config.serverPort);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question