Hello guys
I deploy on app on heroku. I use socket.io to make a chat, it’s work fine on local but i’m can’t making this work online.
I try severals things. I post the last.
In my server side :
const app = express();
const cors = require('cors');
var chat = require('https').createServer(app)
var io = module.exports.io = require('socket.io').listen(chat)
const SocketManager = require('./SocketManager')
io.on('connection', SocketManager)
my client side :
const socketUrl = "https://teachonline.herokuapp.com"
export default class Layout extends React.Component {
constructor(props) {
super(props);
this.state = {
socket:null,
user:null
};
}
componentWillMount() {
this.initSocket()
}
/*
* Connect to and initializes the socket.
*/
initSocket = ()=>{
const socket = io(socketUrl)
socket.on('connect', ()=>{
console.log("chat Connected");
})
this.setState({socket})
}
I got two request when i do that : a get with a 200 as a response and juste after that a 404
You can see by yourselves : https://teachonline.herokuapp.com/chat
I can give you my Github if you want to check something else
If you have any idea of what am i doing wrong, i’m listening. I’m fighint with heroku for hours :’(