How to solve No 'Access-Control-Allow-Origin' header is present on the requested resource with angular 2 service written with angular-cli?
I have a url that pasting it inside the browser will give me a valid json response. Now, from my localhost, from inside angular-cli I'm trying to get that same json from a service and I get this: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 403 I tried to read about this problem, but didn't understand what I need to do in order my service to work. I'm using angular-cli. this.http.get(this.myUrl) .map(res => res.text()) .subscribe( data => this.jsonResult = data, err => this.handleError(err), () => console.log('Random Quote Complete') ); This returns the error I get.
The problem is not with your app. You are trying to access a REST API from the browser and the server handling will need to be set so it accepts CORS requests. It's not possible to give you more info without the back end and that would be a totally different question.
angular-cli#1.0.0-beta.23 (2016-12-15) NOT on npm
Angular cli for existing github project
How to pass config data to NgModule so NgModule will be compiled with AOT
Cloning a repo based on Angular CLI
How can I speed up Angular CLI Live Reload - 1-2 minutes per change
Generating a barrel when calling ng g component <myName>
Setting up tether-drop to work with angular-cli#1.0.0-beta.24
Angular CLI (AOT) gives error: ERROR in Cannot determine the module for class
Angular CLI - ng serve won't run unless I specify port
ERROR in Multistyles…Module not Found (Angular-cli.json)
Angular Cli support for inline templates and css
Angular Cli - How do I rebuild my project
How to change angular 2 port from 4200 to any other
Is autoprefixer active in angular-cli beta 19
How to use nconf with Angular CLI?
angular-cli how to split output js files to vendor and script js file