angular-cli


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.

Related Links

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

Categories

HOME
rest
cakephp-3.x
oauth
drupal-7
ocaml
ubuntu-16.04
fparsec
vs-team-services
wampserver
orientation
propertygrid
value
google-spreadsheet-api
gimp
contact-form-7
google-classroom
hosts
nixos
python-unicode
redux-observable
atlassian-plugin-sdk
eclipselink
device-detection
google-ima
iup
npm-install
python-textprocessing
bus-error
widevine
maximo
pygooglechart
vegan
twitter-bootstrap-2
read-write
graph-databases
qtablewidget
modulo
openpgp
google-guava-cache
codesys
readfile
tic-tac-toe
median
php-ews
rdw
aqgridview
crystal-reports-8.5
createobject
keycode
atlassian-crowd
sql-server-administration
android-navigationview
pydio
qregexp
nssplitview
remoteapp
getrusage
persistence.xml
document-oriented-db
rx-groovy
code-first-migrations
word-2013
google-earth-plugin
python-ggplot
moai
named-ranges
gmaps4rails
errorprovider
method-overriding
sgml
voldemort
manage.py
iconv
client-library
xml-libxml
wpdb
angularjs-timeout
code-conversion
osi
legacy-code
viewdidload
ubuntu-11.04
selectmanycheckbox
surf
testunit
collect
exitstatus
hibernate3-maven-plugin
gwt-2.2-celltable
graniteds
openvg
plinq
swfloader

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App