I have been unable to make a successful call to a URL endpoint due to CORS issues. When I installed a CORS chrome extension, the request went through and returned a valid response with no issues. This is the code below and how can I bypass this CORS error?
const url="http://staging1...";
let data = { 'encrypted request payload'};
let fetchData = {
method:'POST',
body: data,
headers: new Headers({'Content-Type':'application/json'})
}
fetch(url, fetchData)
.then(function(response)){
console.log(response);
}
The response from the above code
Fetch API cannot load http://staging1.... Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.