使用Spring Boot基本身份验证的Angular 6无法正常工作

时间:2019-05-10 10:15:03

标签: spring-boot cors angular6

由于我遵循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

]

0 个答案:

没有答案