When I hit the API, it gives a CORS origin error.
"Access to XMLHttpRequest at 'https://api.faceio.net/setfacialidpincode' from origin 'https://app.stablecrypto.in' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
When I hit the API, it gives a CORS origin error.
✓ Accepted Solution
Hello,
Thank you for reaching out, and welcome to the FACEIO Support Center. To answer your inquiry:
The error you're seeing is related to Cross-Origin Resource Sharing (CORS). CORS is a security feature implemented by web browsers to prevent unauthorized domains from making requests to another domain, which can be potentially harmful. Here's a breakdown of the error message:
- XMLHttpRequest at api.faceio.net/setfacialidpincode documented here. This indicates that there was an attempt to make an XMLHttpRequest (often used for AJAX requests) to the specified URL from your Vue or React web app.
-
has been blocked by CORS policy: This indicates that the browser blocked the request because it violates the CORS policy.
-
Response to preflight request doesn't pass access control check: Before making the actual request, browsers send a "preflight" request (using the HTTP OPTIONS method) to check if the actual request is allowed. This error suggests that this preflight request failed its check.
Solution:
- Simply clear your old browser (development) cache, reload your application, and initiate the API call again.
- If the issue persists, you may refer to this StackOverflow thread at: https://stackoverflow.com/questions/54212220/how-to-fix-access-to-xmlhttprequest-has-been-blocked-by-cors-policy-redirect-i on how to deal with the issue on your frontend..
Let us know if you need further assistance!