Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

CORS Issue while consuming Hana's OData


While trying to consume data from a OData JSON URL from Hana in our local application, we encounter an error as below,

XMLHttpRequest cannot load http//someurl&$format=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:XXXX' is therefore not allowed access.

Since this is clearly a Cross Origin issue, we tried adding CORS parameters as below in .xsaccess file (as in Hana Developer Guide) to allow Cross Origin requests, but we are still shown as same error as above.

"cors" : // Permit cross-origin browser requests [ { "enabled" : true } ]

After going through few posts/blogs, we understood below parameter needs to be enabled in the Response Header of Odata URL,

"Access-Control-Allow-Origin" = "*";

But we are unsure on which file/place we will need to add this parameter.

Please help us in understanding the below queries,

  1. Do we need to add "Access-Control-Allow-Origin" = "*" to request header even of we enable CORS in ".xsaccess" file?
  2. If yes, in which file/place we need to add this package (since we're very much a DB resource we aren't sure on where to add in the Odata hana package) 

Thanks in advance!




Thank you Thomas! Indeed adding CORS entry in .xsaccess file creates the header.

But we found adding the below parameter to getJson allows authentication in CORS of HANA ODATA services,

xhrFields: {withCredentials: true}



0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question