cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CORS Issue when Calling CAP Service from HTML5 Application (Non-UI5)

subhm77911
Explorer
0 Likes
962

I have an HTML5 application built purely with HTML, JavaScript, and CSS (not on SAP UI5), and I need to call a CAP (Cloud Application Programming) service on SAP BTP. When I try to make the request from the front-end, I'm encountering a CORS (Cross-Origin Resource Sharing) issue.

What are the steps to resolve this CORS issue, and how can I configure my CAP service or AppRouter to allow cross-origin requests from my HTML5 app?

Thanks in advance.

#

Accepted Solutions (0)

Answers (2)

Answers (2)

gregorw
SAP Mentor
SAP Mentor

Beside the solution from Wouter I think you should check out the examples at multi-cloud-html5-apps-samples. Either use the custom or managed approuter. Using xs-app.json you configure a proxy to the CAP backend and that way you can avoid CORS issues. Also the Approuter allows you to add authentication. 

WouterLemaire
SAP Mentor
SAP Mentor
0 Likes

I think this might help you: https://community.sap.com/t5/application-development-blog-posts/cap-cors-and-custom-headers/ba-p/136...

 

You could also make the app part of the cap app and deploy it to BTP.