piyushgarg-dev / Scaleable-WebSockets

https://youtu.be/CQQc8QyIGl0?si=u1MZiGSRHGfzWg2B
37 stars 18 forks source link

How to to dynamically determine the server URL #2

Open GauravRawat369 opened 3 months ago

GauravRawat369 commented 3 months ago

if you have multiple servers then why are you hardcoding the server URL as "http://localhost:8000" while making an io connection from frontend

useEffect(() => { const _socket = io("http://localhost:8000"); _socket.on("message", onMessageRec); setSocket(_socket); return () => { _socket.off("message", onMessageRec); _socket.disconnect(); setSocket(undefined); }; }, []);

I hope someone will reply

Soumyadas15 commented 2 weeks ago

In that case you need a reverse proxy to route your requests. Do some research, quite interesting stuff.