chat-app
chat-app copied to clipboard
fix: React doesn't connect to socketIO
Your React Application can't connect to socketIO
Tips to fix this
- Remove socket.io and socket.io-client because you are using very old versions
- Install them again
This is how you can connect now
const http = require("http")
const {Server} = require("socket.io");
const app = require("express")();
const server = http.createServer(app)
const io = new Server(server, {cors: {origin: 'http://localhost:3000'}});
io.on("connection", socket => {
console.log("connected");
})
const port = process.env.PORT || 5000;
server.listen(port, () => console.log(`Listening on port ${port}`))