I developed an API in node.js and deployed it in cloud platform but while calling that API from SAP cloud platform, I am getting CORS error as below:
jquery-dbg.js:9208 Access to XMLHttpRequest at 'https://xxxxx.cfapps.us10.hana.ondemand.com/xxxxx' from origin 'https://webidetestingxxxxxxxxxxx.dispatcher.hanatrial.ondemand.com' has been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response
$.ajax({
type: "POST",
url: "https://xxxxxxx.cfapps.us10.hana.ondemand.com/xxxxxx",
contentType: "application/json; charset=utf-8",
dataType: "json",
crossDomain: "true",
async: false,
headers: {
"Authorization": "Basic" + "***********",
"Access-Control-Allow-Origin": "*"
},
data: JSON.stringify({
text: "hi",
subject: "body message"
}),
success: function (data) {
console.log("success" + data);
},
error: function (data) {
console.log("error: " + data);
}
});
Although I am using "Access-Control-Allow-Origin" in the header, no luck so far. Any help is much appreciated.