Reputation: 151
I have created a sample SAPUI5 application in online editor
Check this link to view my code
I am getting this below error -
> XMLHttpRequest cannot load
> http://services.odata.org/V2/Northwind/Northwind.svc/Products?$format=json.
> No 'Access-Control-Allow-Origin' header is present on the requested
> resource.
Can someone help me in solving this issue - I understand that it is CORS issue which can be solved by disabling the security in chrome.
However - I don't to disable the security feature of chrome. So, is there any other way (probably by passing some headers) to solve this issue.
Appreciate your help in advance.
P.S.: I have already looked in these links -
http://scn.sap.com/community/gateway/blog/2014/09/23/solve-cors-with-gateway-and-chrome
Upvotes: 0
Views: 5167
Reputation: 6190
If this is just for the purpose of testing, the following solution should be the easiest.
Use a proxy service which adds the needed headers, for example the following: https://github.com/Rob--W/cors-anywhere
Usage is really simple, just add the URL of the proxy service before your OData URL:
var uri = "https://cors-anywhere.herokuapp.com/https://services.odata.org/V2/Northwind/Northwind.svc/Products?$format=json";
Upvotes: 0
Reputation: 843
add the northwind odata service as a destination under the DESTINATIONS tab of your hcp account. Then make an ajax call to the northwind services using relative path i.e. /destination/..... Or make your own java application that works as proxy which allows source as and re-routes the payload to the correct destination.
basically destination is also a proxy supplied for out of the box usage by sap
Upvotes: 1