Currently, I am attempting to make a POST request to a REST API within the Office Outlook web add-in using AJAX calls. Despite configuring the app domains in the manifest.xml file for the target URL, I am encountering CORS issues.
The error message reads: Access to XMLHttpRequest at 'https:' from origin 'https:' has been blocked by CORS policy, indicating that the request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in the preflight response.
I have been unable to pinpoint the exact reason for this issue and what may be causing it.
Sharing below some relevant code snippets from MessageRead.js:
$.ajax({
type: "POST",
dataType: "json",
url: "<target url>",
contentType: 'application/json',
crossDomain: true,
headers:
{
'X-Database': 'aln_template',
},
data: {
//id: "1598521065618",
id: (new Date()).getTime(),
method: "execute",
params: params
},
success: function (data1) {
}
});