I am trying to do a issue search by using jira rest api.
with basic authentication
I did try add this server to jira whitelist
$.ajax({
type: 'GET',
url: jiraApiBaseUrl + 'project?expand=JIR',//'issue/' + 'JIR-197',
dataType: 'json',
//jsonp: 'jsonp-callback',
timeout: issueTimeout,
success: function(data) {
console.log('200. Returned status of ' + data.status);
},
error: function(xhr) {
console.log('Request failed. Returned status of ' + xhr.status);
},
beforeSend: function(xhr, settings) {
xhr.setRequestHeader('Authorization',authCredentials);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader("Access-Control-Allow-Origin", "https://abc.com");
xhr.setRequestHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
}
});
$.ajaxPrefilter( function( options, originalOptions, jqXHR ) {
options.crossDomain ={
crossDomain: true
};
options.xhrFields = {
withCredentials: true
};
});
});
I have found the error below:
Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘null’ is therefore not allowed access.
There are some posts which also talked the same problem, but looks like not work for me.