简体   繁体   中英

Getting CORS error in AngularJS when accessing data form REST URI

XMLHttpRequest cannot load http://hfdvcbapp01.vm.itg.corp.us.shldcorp.com:8180/cnb/cnb/report/summary?Company=IT . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://127.0.0.1:64033 ' is therefore not allowed access.

I am getting this error when i am trying to load data from json which situated at the server.How can i resolve this.

Your api is not returning header

Access-Control-Allow-Origin: http://yourdomain.com

to allow specific domain

or

Access-Control-Allow-Origin: *

to allow all

PS. Also make sure that headers are actually there. Pay attention that CORS actually send 2 requests 1 will be OPTIONS , second will be actual request so if you return headers only on GET or POST it wont work. To check it in chrome presss f12, go to network and do you requests make sure that header is there Read more

Access-Control-Allow-Origin header should be set in the response,

if it is not from the same origin of the URL it was sent from, the header should be set from the respone - meaning - the server responding to the request in youre case - http://hfdvcbapp01.vm.itg.corp.us.shldcorp.com:8180 , if the server is under youre control just handle it, if its an outside service you should request this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM