由于我遵循6号角代码,因此出现401错误
var headers_object = new HttpHeaders();
headers_object.append('Accept', 'application/json');
headers_object.append('Content-Type', 'application/json');
headers_object.append('Authorization', 'Basic YWRtaW4xOnNlY3JldDE=');
const httpOptions = {
headers: headers_object
};
我正在这样调用Spring Boot服务
return this.http.get('http://localhost:8080/pocapp/courses', httpOptions);
在Spring Boot应用程序中获取以下日志
Host: localhost:8080
Connection: keep-alive
Accept: application/json, text/plain, */*
Origin: http://localhost:4200
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36
Referer: http://localhost:4200/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
]