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

94
Views
Cookie not being set from header

I'm trying to solve the problem of a cookie not being set on the client after it receives it from the server.

When I log in, I get this response: enter image description here

Note that the allow credentials header is present & the cookie is being received.

The problem starts when I call /auth/refreshToken. The cookie is never set and so it's never received when the post request is made. I think this is a problem on the client side but I can't figure it out.

I make a post request to this endpoint like this:

const response = await fetch(`http://localhost:3001/auth/refreshToken`, {
    method: 'POST',
    headers: {
      Accept: 'application/json',
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${jwtBearer}`, 
    },
    credentials: 'include',
    body: JSON.stringify({ 
      "input": {
        "refreshToken" : refreshToken,
        "fingerprintHash" : fingerprintHash
      }
    }),
  })

On the server, I've configured CORS like this:

const corsOptions = {
  credentials: true,
  origin: process.env.NODE_ENV === "production" ? 
  'https://example.com'
  : 
  'http://localhost:3000'
};

app.use(cors(corsOptions));

I've looked at all the answers to the following questions, which mention to add credentials: 'include' and add cors options to allow the Set Cookie header and credentials. Nothing has worked.

about 4 years ago · Juan Pablo Isaza
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!