'Failed to load resource: Preflight response is not successful

Am trying to call CORS Rest API but am getting this error:

Failed to load resource: Preflight response is not successful

This happens on my cordova apps after upgrading to iOS10, before that it used to work normally!

Here are the request/response headers, it does not complain about a specific header it only gives the above message!

request/response headers



Solution 1:[1]

If you're still experiencing this issue, it appears to have been solved here. The recommended solutions were:

Solution 2:[2]

just insert below code in app.js just above routes

app.use((req, res, next)=>{
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Headers', 'authtoken,content-type,application/json, text/plain, */*');
  if(req.method==='OPTIONS')
  {
      res.header('Access-Control-Allow-Methods', 'GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE, PATCH');
      return res.status(200).json({});
  }
next()
})
// routes middleware
readdirSync("./routes").map((r) => app.use("/api", require("./routes/" + r)));



`````

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Aaron Meese
Solution 2 Kishor Gunjal