I'm new on this and I think this question will be easy for u, but please help.
I need to make on loading page http request and it's working but my query is blocked with message
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:9999/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
There is my code of Angular :
export class AppComponent implements OnInit {
public apiURL:string = 'http://localhost:9999/';
public logged: boolean;
response: any;
constructor(private elementRef:ElementRef, private http:Http) {
this.logged = this.elementRef.nativeElement.getAttribute('auth');
}
ngOnInit() {
this.checkLogin()
}
checkLogin() {
this.response = this.http.post(this.apiURL, {"search": "search"}, ).map(res => res.json()).subscribe(data => {console.log(data);});
}
}
I already tried a many variants.. but no one is not working for me... could someome provide little example of resolving it... please...