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:
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?