2
votes

I created several SAPUI5 web applications in Eclipse that have been deployed to a SAP NetWeaver PO 7.5 Application Server.

All these applications use generic components of a "common" project. I just made them available via the html header with this bootstrapping script-tag:

<!-- Bootstrapping UI5 -->
<script id="sap-ui-bootstrap"
        src="/sapui5/resources/sap-ui-cachebuster/sap-ui-core.js"
        data-sap-ui-libs="sap.m"
        data-sap-ui-theme="path.to.custom.theme"
        data-sap-ui-compatVersion="edge"
        data-sap-ui-resourceroots='{"com.namespace.ui.specificapp": ".", "com.namespace.ui.common" :"/com.namespace~ui~common~web"}'
        data-sap-ui-frameOptions="trusted"
        data-sap-ui-appCacheBuster = "./,/com.namespace~ui~common~web/" >
</script>

This worked fine until I tiered to transfer these applications to SAP Cloud.

I imported the projects to WebIDE and first thing I discovered was that data-sap-ui-resourceroots attribute doesn't work anymore because application cannot find the components from the common project. So I deployed the common application to SAP Cloud and inserted the corresponding URL in the bootstrapping script-tag of the index.html like this:

<script id="sap-ui-bootstrap"
    src="/sapui5/resources/sap-ui-cachebuster/sap-ui-core.js"
    data-sap-ui-libs="sap.m"
    data-sap-ui-theme="path.to.custom.theme"
    data-sap-ui-compatVersion="edge"
    data-sap-ui-resourceroots='{"com.namespace.ui.specificapp": ".", "com.namespace.ui.common" :"/https://common-aXXXXXXXX.dispatcher.hana.ondemand.com/"}'
    data-sap-ui-frameOptions="trusted"
    data-sap-ui-appCacheBuster = "./,/com.namespace~ui~common~web/" >

This allows browser to find the JS-files from the common project, but leads to this error:

Note: Your browser does not support JavaScript or it is turned off. Press the button to proceed.

This is message is thrown by the https://common-aXXXXXXXX.dispatcher.hana.ondemand.com/ host.

Analysing the HTTP request I see that the parameter Accept:text/plain, */*; q=0.01 is set.

I don't know why SAPUI5 is requesting plain text or where I can change this behavior. Does anyone know how to tranfer this application structure to the SAP Cloud?

1
Have you defined a link to your common app in the neo-app.json file?Andrii Naumovych

1 Answers

2
votes

The answer is pretty easy: The server blocks requests to other origins to prevent CSRF attacks. In the on premise solution all source files come from the same origin: the own server. In the SAP Cloud each application is deployed standalone with its own URL. Therefore the browser doesn't accept JavaScript files from other projects. The solution to access these files is to add the URL of the common project to the destinations in the SAP Cloud Cockpit.

FYI: Including the URL in the destinations enables you to use a relative URL for referring to external JavaScript files, so that they aren't blocked by the browser.