Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!