api CORS issue from jira rest api to sonarqube

Khan December 23, 2020

Hi Community,

I've the following ajax call from confluence to sonarqube:

// Sonarqube data AJS.$.ajax({ url: 'https://sonarqube.xx/api/prometheus/metrics', type: 'GET', dataType: 'json', "crossDomain": true, 'cache': false, contentType: 'application/json', beforeSend: function(xhr) { xhr.setRequestHeader('Authorization', "Basic " + btoa("xx" + ':' + "xx")); }, headers: { "Authorization": "Basic " + btoa("prom" + ':' + "prom"), "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET, POST, PATCH, PUT, DELETE, OPTIONS", "Access-Control-Allow-Headers": "Origin, Content-Type, X-Auth-Token", "Access-Control-Expose-Headers": "Content-Length, X-JSON" }, success: function(json) { console.log(json) }, error: function(err) { console.log(err) } });

however, I'm getting the following error:

Access to XMLHttpRequest at xx from origin 'https://www.xx.de' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I was informed by the sonarqube admins that its not possible to add CORS on the sonarqube side. Is there still a way to get sonarqube data.
Please note that postman access to the sonarqube is fine using basic authorization.

Thanks in advance

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events