I am trying to access my database tables from SAP HANA, and I am encountering a CORS issue I believe in accessing the data without ta Access-Control-Allow-Origin Error, and of all the resources I've been looking at haven't solved the issue yet.
So I have created a cloud connector port to connect to a destination I have setup in my SAP HANA Cloud Platform Cockpit, which I am trying to access from my SAP WebIDE. I am trying to access a few tables from SAP HANA, so I created a XS project with the following .xsacccess
file:
{
"exposed" : true,
"authentication" :
{
"method": "Basic"
},
"cache_control" : "must-revalidate",
"cors" :[{
"enabled" : true,
"allowMethods": [
"GET",
"POST",
"HEAD",
"OPTIONS"],
"allowOrigin" : ["*"],
"exposeHeaders": "access-control-allow-headers,Access-Control-Allow-Origin,access-control-expose-headers,authorization",
"allowHeaders":"Origin, Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control",
"maxAge" : "3600"
}],
"headers" : {"enabled": true},
"enable_etags" : true,
"force_ssl" : true,
"prevent_xsrf" : false,
"allowCredential":true,
"anonymous_connection": null
}
And the following .xsodata
file:
service {
"HD"."TESTCASES" as "TESTCASES";
"HD"."FAILCASES" as "FAILCASES";
}
I setup my CORS in the XS Admin Tool as the following:
I am trying to call the service with the SAPUI5 command:
var newModel = new sap.ui.model.odata.v2.ODataModel("https://webidecp-i863039trial.dispatcher.hanatrial.ondemand.com/destinations/Hana/oDataAcess/oData.xsodata", {
headers: {"Access-Control-Allow-Origin" : "*"},
user: "XXXXX",
password: "XXXXXX",
withCredentials: true
});
But I am getting the popular error message:
Failed to load https://webidecp-XXXXXXXtrial.dispatcher.hanatrial.ondemand.com/destinations/Hana/oDataAcess/oData.xsodata/$metadata: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://webidetesting3106899-XXXXXXXtrial.dispatcher.hanatrial.ondemand.com' is therefore not allowed access.