4

My setup is SonarQube (localhost:9000) and Angular 4 instance (localhost:4200). I can successfully perform a GET request with Angular from SonarQube without authorization. However, after adding http basic auth headers, the same request fails with "Response for preflight has invalid HTTP status code 405."

This is my GET request:

const headers = new HttpHeaders().append('Authorization', 'Basic ' + btoa('admin:admin'));
this.http.get('http://localhost:9000/api/components/search?qualifiers=DIR', { headers: headers }, )
  .subscribe(data => {
    console.log(data);
  });

Chrome output:

enter image description here

I have tried adding CorsFilter to web/WEB-INF/web.xml according to tomcat documentation, but it did not change the response headers. How to correctly enable Cross-Origin Resource Sharing in SonarQube?

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
Gustavs
  • 85
  • 1
  • 7
  • 1
    I tried to do something similar but as far as I know the Sonar team refuse to add support for CORS. No idea, why they developed a web api in the first place when they don't allow ajax calls to it. – T3rm1 Mar 06 '18 at 11:15

0 Answers0