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

281
Views
How to check CORS Preflight response status code in js?

Is there any way to get a status code of a CORS Preflight response? Preflight response

I would like to make a condition for status of Preflight request.

The code I have right now:

let requestInCheck = new XMLHttpRequest();
requestInCheck.open("GET", "http://google.COM/", true); //CORS
requestInCheck.setRequestHeader('Cache-Control', 'no-cache');
requestInCheck.timeout = TIME_OUT;

requestInCheck.onerror = () => {
  console.log(`There was an error while trying to make the request [STATUS: ${requestInCheck.status}]`);

  serviceAcception = false;
   
  this.setState({ serviceAcception });
}

requestInCheck.onload = () => {
  console.log(`The response code is [STATUS: ${requestInCheck.status}]`);

  if(requestInCheck.status !== 0) 
    serviceAcception = true;
   
  this.setState({ serviceAcception });
} //...send method is below

Since the request is unable to be responded correctly, "onerror" is called and respectful message is logged: Console

Is there a way I can get preflight status code into some variable or smth?

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!