Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js SSL:Heroku、Nodejs、Socketio、ReactJS_Node.js_Ssl_Heroku_Socket.io_Reactjs - Fatal编程技术网

Node.js SSL:Heroku、Nodejs、Socketio、ReactJS

Node.js SSL:Heroku、Nodejs、Socketio、ReactJS,node.js,ssl,heroku,socket.io,reactjs,Node.js,Ssl,Heroku,Socket.io,Reactjs,我正在将一个应用程序部署到Heroku,一切正常,应该是实时的,但是如果你看到控制台不工作,我就得到了这个错误 Mixed Content: The page at 'https://poke-chat.herokuapp.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://localhost:3000/socket.io/?EIO=3&transport=polli

我正在将一个应用程序部署到Heroku,一切正常,应该是实时的,但是如果你看到控制台不工作,我就得到了这个错误

Mixed Content: The page at 'https://poke-chat.herokuapp.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://localhost:3000/socket.io/?EIO=3&transport=polling&t=1441366303148-19'. This request has been blocked; the content must be served over HTTPS
我不知道为什么:c

这是我的index.js

import express from 'express';
import http from 'http';
import engine from 'socket.io';
import dbapi from './db-api';

const port = process.env.PORT || 3000;
const app = express();

//Ruta de archivos estaticos

app.use('/', express.static(__dirname + '/public'));

app.get('/pokemons', (req, res) => {
    dbapi.pokemons.find((pokemons) => {
        res.json(pokemons);
    })
});

app.get('/', (req, res) => {
    res.sendFile(__dirname + '/index.html');
});

let server = http.createServer(app).listen(port, () => {
    console.log(`El servidor esta escuchando en el puerto ${port}`);
});

const io = engine.listen(server);

io.on('connection', (socket) => {
    socket.on('message', (msg) => {
        io.emit('message', msg);
    })
})
谢谢您的帮助:p

问题 这是服务器端代码,看起来不错

问题似乎出在客户端代码上,您似乎正在请求

http://localhost:3000/socket.io/?EIO=3&transport=polling&t=1441366303148-19

解决方案: 将域更改为指向
https://poke-chat.herokuapp.com/
而不是
http://localhost:3000

希望它能帮助解决这个问题 这是服务器端代码,看起来不错

问题似乎出在客户端代码上,您似乎正在请求

http://localhost:3000/socket.io/?EIO=3&transport=polling&t=1441366303148-19

解决方案: 将域更改为指向
https://poke-chat.herokuapp.com/
而不是
http://localhost:3000


希望对您有所帮助

谢谢,很高兴您喜欢它!:谢谢你,很高兴你喜欢它D