cancel
Showing results for 
Search instead for 
Did you mean: 

Access-Control-Allow-Origin issue

Former Member
0 Kudos

Dear All,

i am trying the sencha odata connector to consuming the flight service(http://sapes1.sapdevcenter.com:8080/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/).

but with the error "Origin http://localhost is not allowed by Access-Control-Allow-Origin.", i still cannot get the data from the flight.

and i already set the properties in the proxy.

withCredentials: true,
useDefaultXhrHeader : false,

here is the odata connector links       Sencha Touch OData Connector for SAP Sencha Connector: Data —    Sencha Market(and the sample code is in the zip)

anybody could help me on this?

thank you very much

best regards

lawrence

Accepted Solutions (0)

Answers (2)

Answers (2)

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

You could also while developing the app locally on your laptop pass the below option to Chrome.  Note you will need to close all running instances of Chrome before this setting takes effect.  There will be a message shown when Chrome opens indicating that the setting is in effect.


--disable-web-security

Former Member
0 Kudos

The reason you are getting "Origin http://localhost is not allowed by Access-Control-Allow-Origin." is because you are trying to make a cross-origin call. Your Sencha Touch code is on http://localhost and you are trying to get data from a different domain, in your case it is:

http://sapes1.sapdevcenter.com/

The same-origin policy enforces that browsers only allow Ajax calls to services in the same domain as the HTML page.

There are two easy ways to make a cross-origin call:

  1. Enable the necessary CORS headers on the server (localhost).
  2. Use JSONP instead of JSON.

References:

jquery - Access-Control-Allow-Origin error - Stack Overflow

http://stackoverflow.com/questions/19821753/jquery-xml-error-no-access-control-allow-origin-header-i...