SAP-samples / cloud-cap-samples-java

A sample application that demonstrates the features of the Java SDK for the SAP Cloud Application Programming Model.
https://cap.cloud.sap
Apache License 2.0
142 stars 142 forks source link

Preview fails to load #317

Closed MdImamHasan closed 6 months ago

MdImamHasan commented 6 months ago

Hi, After generating a sample app on the provided cloud cap samples service (e.g. authors) and starting a preview via mvn spring-boot:run, we are running into issues with the empty preview. image It is showing the following error in the console: image My assumption S/CUBE is not supported is causing this error. Could you please check and verify that the preview is working fine? Thanks

beckermarc commented 6 months ago

I think the root cause is rather

Refused to execute script from '.../Component-preload.js' because its MIME type ('application/json') is not executable and strict MIME type checking is enabled."

I am wondering why a .js file gets application/json as MIME type. It should rather get text/javascript. This seems also to be the case for the provided webapps in the sample and their Component.js file.

What's the content of this file? Are you on the main branch version of the sample otherwise?

MdImamHasan commented 6 months ago

Yes. I am on the main branch of the sample app. I am unsure about the MIME type and unable to see the file content. During further investigation, it is clear that the issue is with the URI in the data sources section of the manifest.json file. if we changed it from "uri": "/odata/v4/browse/", to "uri": "/api/browse/", then the preview works. I can see a similar issue reported here https://github.tools.sap/cap/issues/issues/15092 Maybe a similar fix is needed again. Thanks

beckermarc commented 6 months ago

Our sample application reconfigures the default base path from /odata/v4 to /api. It might very well be that the Fiori generator doesn't take this configuration into account. As you noted there was a fix in the past already in that area. So please make sure the Fiori generator you are running is using @sap/cds >= 7.6.0.