Failed to load URL: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
Is it possible to fix this from Angular2 without changing the code in server side (Java Spring Controller)?
My code
const headers = new Headers({'Content-Type': 'application/json',
'Access-Control-Allow-Origin' : '*'
});
return this.http.get(url, {headers: headers})
.toPromise()
.then(response => response.json().data as Hero[])
.catch(this.handleError);