I'm trying to connect api hosted on cloud and getting 403-Forbidden due to CORS issue.
var url = "https://spring-demo-ysyfl4f26q-uc.a.run.app/getsummary";
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myArr = JSON.parse(this.responseText);
myFunction(myArr);
}else{
myFunction('errorcode'+this.status+' error'+this.readyState+this.responseText);
}
};
xmlhttp.open('GET', url);
xmlhttp.setRequestHeader('Access-Control-Allow-Origin', '*');
xmlhttp.setRequestHeader('Access-Control-Allow-Methods', 'GET, PUT, POST, DELETE, HEAD, OPTIONS');
xmlhttp.setRequestHeader('key', 'PRODUCT');
xmlhttp.setRequestHeader('Content-Type', 'application/json');
xmlhttp.setRequestHeader('Access-Control-Allow-Headers', 'Content-Type, key,Access-Control-Allow-Headers,Access-Control-Allow-Origin, X-Requested-With');
xmlhttp.withCredentials = false;
xmlhttp.send();
script.js:75 GET https://spring-demo-ysyfl4f26q-uc.a.run.app/getsummary 403 (Forbidden)
Can anyone help in this, i'm able to get response via POSTMAN ? TIA