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

addons removed in angular-cli.json whats the replacement
angular-cli: ng serve command with config error
Augury Angular-cli When I installed the augury .Error is as follows
Teamcity for building Angular cli app
angular cli update issue on local folder
Access to -aot parameter in code
Missing peer dependencies after installing latest angular-cli: What to do?
angular-cli ng serve : Error: No errors
Getting error after Angular cli update
Does angular-cli uses rollup to do ahead-of-time compilation and adding all into one file?
Angular CLI install error
Using glob for assets in angular-cli throws error
Importing Global SCSS into Component SCSS with Angular-CLI
Error during AOT build with angular-cli 24 and Angular 2.4.1
Add importer to node-sass in angular-cli project
angular-cli#1.0.0-beta.23 (2016-12-15) NOT on npm

Categories

HOME
python
sql-server-2008
jenkins-plugins
jasmine
google-sheets-api
amazon-product-api
extract
ruby-on-rails-3
javamail
specflow
file-io
urlencode
requirejs
contact-form-7
octopus-deploy
ctypes
webmethods
squarespace
sign
mod-pagespeed
scala-native
lstm
jquery-terminal
riak-ts
cairo
jsonserializer
sonarqube-msbuild-runner
remove-method
continuous-deployment
bus-error
data-conversion
stocks
node-horseman
boilerplate
mms
xamarin.uitest
initializer
mongoexport
silverlight-3.0
delphi-10.1-berlin
crop
openweathermap
aqgridview
broadcast
tiddlywiki
windows-95
text-classification
ruby-on-rails-2
httplib2
gmt
bettercms
gradle-script-kotlin
activeweb
radians
scalar
metalsmith
boost-hana
qt-linguist
fill
asymptote
file-diffs
data-import
site-prism
lmfit
registrykey
debian-based
web-component-tester
jazz
viewflipper
utf-32
sysctl
gmaps4rails
odftoolkit
ogr2ogr
libssh2
outline
facebook-wall
alpha-transparency
smartystreets
pic24
gfs
pyjade
image-zoom
threadx
awesomeprint
arbor.js
xml-libxml
android-contextmenu
marmalade-edk
dropdownlistfor
maven-ear-plugin
sunspot-rails
scrollto
nssavepanel
mysql-error-1045
exitstatus
hardware-acceleration
gwt-2.2-celltable
mvvm-foundation
web-statistics
winsnmp
evb
standardized
document-library
dotproject

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