请求 header 字段 Authorization is not allowed by Access-Control-Allow-Headers in preflight response(Jenkins API)

Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response(Jenkins API)

我在尝试使用 angular 服务访问 Jenkins API(https://jenkinsbox:3000/api/json) 时看到以下错误,并在 headers 中提供基本身份验证。

错误:

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;
    }))
 }

并使用 CORS 支持插件在 Jenkins 中配置 CORS -

我想我在 Jenkins 端的 "Access-Control-Allow-Headers" 中遗漏了一些东西。请协助

我认为您还需要允许授权 header。 所以将 Authorization 添加到 Access-control-Allow-Headers