Cześć,
Problem jaki próbuję rozwiązać to:
Access to XMLHttpRequest at 'http://localhost:8080/Credits' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Uruchamiam aplikację w Angularze (port 4200) i próbuję wysłać zwykłego GET
-a na drugi server, który uruchomiony jest na SpringBoocie (port 8080).
Doczytałem, że mam dodać Header : 'Access-Control-Allow-Origin': '*'
jednakże to nie pomaga. Ma ktoś inne rozwiązanie tego problemu? ;)
public getCredit(url: string) {
const header = new HttpHeaders({
'Access-Control-Allow-Origin': '*'
});
const options = {headers: header};
this.http.request('GET', url + '/Credits', options).subscribe(
res => console.log(res), err => console.log(err));
}