Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

121
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda