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

246
Views
Send AJAX calls from main domain to subdomain

I know this may have been answered already but none of the solutions I found are working for me.

I have an AJAX call from example.com to api.example.com/v1, when sending the request, no cookie is sent.

EDIT:

My AJAX code is

$.ajax({
    type:"POST",
    url:"https://api.example.com/v1/",
    data: payload,
    processData: false,
    xhrFields: { withCredentials:true },
    crossDomain: true,
    xhrFields: { responseType: 'arraybuffer' },
    dataType: 'binary',
    contentType: 'application/octet-stream',
    headers: { "Csrf-Token": csrfValue, "accept": "application/octet-stream"},
    success: function(res) {
        // Some code here
    }
});

EDIT 2:

The headers set by the server on the preflight request are:

access-control-allow-credentials: true
access-control-allow-headers: Content-Type, Csrf-Token, Cookie
access-control-allow-methods: OPTIONS, POST
access-control-allow-origin: https://example.com
allow: OPTIONS, POST

EDIT 3:

My cookie values are:

Name: __Secure-Csrf-Token
Content: 4XAlnRWR95FKGcpYxZb6P9xxtFx1hP7XXU8rSShpnEY
Domain: .example.com
Path: /
Send for: Secure same-site connections only
Created: Wednesday, May 25, 2022 at 11:18:17 PM
Expires: When the browsing session ends

And yes, mi site uses HTTPS.

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

0

Okay so it looks like I was repeating the xhrFields param, so the first mention where I set the withCredentials: true was being overwritten.

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!