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

106
Views
AJAX not sending my cookie to NODE JS SERVER

I have an API in NodeJs where I need to validate a token to let a user pass that middleware and retrieve storeId. I have a cookie with ts key in my localhost : cookie ts in application dev tools

And I have my AJAX call.

$.ajax({
    type:'POST',
    dataType: 'JSON',
    url: 'http://www.localhost:8090/product',
    data: product,
    xhrFields: { withCredentials: true },
    crossDomain: true,
    async: false,
    success: result => {
        console.log(result)
        $('#FormLoading').remove()
    }
})

And for some reason it still doesn't send the token but in other pages like homepage dashboard it works. response

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The ts key is for localhost domain and you are calling http://www.localhost:8090/product. Normally if the domain of your cookies are like the domain of the API URL, the cookie key and its value will be inserted in the header request automatically as a string series. But here the domain of your cookie is localhost and domain of the API is www.localhost. So AJAX ignores the cookie.You should set the cookie domain with wildcard, when generating cookie in node js server response to login request, or change the base URL of the API to localhost. By the way this may help How do browser cookie domains work?

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!