I am playing a bit with Angular2 structure and I got to the point where I want to pull information from the server.
Now, my api's domain is different from the FrontEnd app, and I am expecting that the browser will fire OPTIONS
request before executing the actual one. However, that is not happening. Instead, what I get is an error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8080/rrm/api/v1/goals. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
And my network log looks like this:
My dead simple Angular2 code is as follows:
export class AppComponent implements OnInit {
goals: Object[];
constructor(public authHttp: AuthHttp) {}
ngOnInit():any {
this.getGoals();
}
getGoals() {
this.authHttp.get('http://localhost:8080/rrm/api/v1/goals')
.subscribe(
data => this.goals = data.arrayBuffer(),
err => console.log('Error ', err),
() => console.log('Request Complete')
);
}
}
What am i missing? I am not getting options
request on the server and I don't see it in the browser...
Thanks,