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

122
Vistas
How to send data between two different port on one application

I'm using expressjs library. It works on localhost:8000 as a server and i'm showing static pages with it. My application works on localhost:4200. I tried to use same cookie or localStorage on different pages of ports but it didn't work. How can i achieve this?

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

0

You can do this by calling the routes on localhost:8000 in your main application only, and since it is working on two different ports you may run to error due to Cors policy and for that you may look up to these answers. cors enable

about 4 years ago · Juan Pablo Isaza Denunciar

0

When you're working on different ports, if the cookies have the 'SameSite' attribute set to 'Host Only' and the domain set to 'localhost', they will be visible/accessible from both domains regardless of the port number.

As @codingmaster says, if it's different domains, you will have to implement cors management for different domains..

But since you own both applications, during production, one can be on the main domain while the other on a subdomain, then you'll have to set the domain attribute of the cookie to your domain, e.g: example.com and the SameSite attribute can remain HostOnly and the cookies will be accessible

about 4 years ago · Juan Pablo Isaza Denunciar

0

What I think you are trying to do here is have the cookie/local storage shared between two locations.

  1. Do you need 2 locations? I'm pretty sure you can serve your app on the same express server.
  2. If you are using the express one for backend (not frontend), you can pass the required information within your requests, with POST, GET, PATCH, etc. Have a google for more info on sending info between a client and server.
  3. If both are frontend, maybe try to not have it that way. If it's necessary, you can use what I mentioned above to send info between the servers.

Hope this helps in some way.

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