This is my server side code for socket intialization
const { createServer } = require(“http”);
const { Server } = require(“socket.io”);
const httpServer = createServer(app);
const io = new Server(httpServer, {
cors: {
origin: “https://ui-url”,
methods: [“GET”, “POST”],
},
});
httpServer.listen(3000);
This is my client side code for connecting to socket
useEffect(() => {
const s = io('https://backend-url.com');
setSocket(s);
console.log("socket", s);
return () => {
s.disconnect();
};
}, );
→ I get this error in my browser console, not able to establish, the socket connection ,can anyone help?
WebSocket connection to ‘wss://backend-url.com/socket.io/?EIO=4&transport=websocket’ failed: