Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

376
Vistas
Socket.io chat application working only on localhost

I'm completely new to web sockets and javascript. I'm trying to create a chat application using javascript and socket.io. It works on localhost (using "npm start" command line).

My question is: how can I access it from any other PC and use it like a real chat application?

I have the following error when I don't access it on localhost:

error

How can I host it for free and access it from anywhere? Can someone provide me an example of a socket.io chat application and step-by-step instructions?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It does not work because if you are accessing to your website not from localhost, your hostname will not be the server address. So, in your var socket = io(); you can specify the url that the user is accessing your website from.

Like this:

// get the url
let url = window.location.href.split("/");
url = url[0] + "//" + url[2];

const socket = io(url);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda