cancel
Showing results for 
Search instead for 
Did you mean: 

Avoid CORS problems for C4C OData service called from SAPUI5 application?

Former Member
0 Kudos

I am having a few problems with cross-origin policy while trying to access the C4C Odata service. The application is hosted as a BSP application on an ABAP system.

As per the guide (https://github.com/SAP/C4CODATAAPIDEVGUIDE), i am trying to make a simple call to retrieve the x-csrf-token to use in subsequent calls.

Any request made to the domain https://my*****/sap/c4c/odata/v1/c4codata/ is blocked due to CORS issues. I need to add a request header {"x-csrf-token":"fetch"} that triggers a preflight OPTIONS request, which does not allow authentication and fails.

I tried with xhr requests, ajax requests and odata models, but to no result.

What could I do to solve this issue?

Edit: I tried different borwsers to make sure and it is not a Chrome specific issue.

Accepted Solutions (1)

Accepted Solutions (1)

Hello Giovani,

Currently CORS is not supported in C4C OData consupmtion.

This functionality will be made available in one of the future releases of C4C.

Daniel_KASIMIR
Participant
0 Kudos

Hi Aelia,

any news on that? Is it possible to enable CORS now somehow?

Regards

Daniel

RNL
Explorer
0 Kudos

Hi,

since three years no (good) news here - maybe you want to vote for this Idea https://influence.sap.com/sap/ino/#/idea/277034

Regards, René

Answers (2)

Answers (2)

Andre_Fischer
Product and Topic Expert
Product and Topic Expert

Hi Giovanni,

since C4C does not support CORS as Aelia Azevedo wrote above you could also try out one of the following two options:

1) use a reverse Proxy that has to be placed in front of both systems. (for example a SAP web dispatcher)

2) use the following workaround for CORS that has been described by dong.pan in his blog https://blogs.sap.com/2017/02/08/how-to-enable-cors-on-sap-netweaver-platform/

Best Regards,

Andre

Former Member
0 Kudos

Unfortunately solution 2 does not fit my necessities, I will have to find an alternative way. Thank you very much for the answer!

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Option 1) always works.

GregMalewski
Contributor

Hi, Do you have the issue with the simple GET request?

Former Member
0 Kudos

I do, unfortunately as per Aelia Azevedo's answer it is still an unsupported functionality in C4C. Thank you anyway!