I see below error when trying to access Jenkins API(https://jenkinsbox:3000/api/json) using angular service with Basic authentication providing in headers.
Error:
Failed to load http://jenkinsbox:30000/api/json?&tree=jobs[name]: Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.
httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'Basic ' + btoa('username:password')
})
getjobslists(): Observable<jobs[]>{
this.url = "https://jenkinsbox:3000/api/json"
console.log("getting data..")
return this.http.get<jobs[]>(this.url + "/api/json?&tree=jobs[name]",this.httpOptions)
.pipe(map(function(res){
//console.log(res);
return res;
}))
}
And configured CORS in Jenkins using CORS Support plugin -
I think I'm missing something in "Access-Control-Allow-Headers" from Jenkins end. please assist