cloud-cap-samples-java
cloud-cap-samples-java copied to clipboard
Login pop-up is not shown when starting the Fiori application
Hello CAP experts,
I used this CAP Java project and generated inside of it a Fiori elements List Report application. The application is called authors
Now I want to use a slightly different approach to run the Fiori application in the browser. What I do is the following:
- I am executing
mvn spring-boot: run
in the root folder of the CAP project, build is successful and the Tomcat server is started onlocalhost:8080
- In a new terminal, I am navigating to the root folder of the Fiori application
/app/authors
and executingnpm start
. This starts an express server with a proxy middleware onlocalhost:8081
. The proxy middleware will forward any backend requests to the Tomcat server onlocalhost:8080
- But now when open
http://localhost:8081/test/flpSandbox.html?sap-ui-xx-viewCache=false#authors-tile
, I immediately get a 401 Error
I noticed that if I open the application from the Tomcat server, hence opening http://localhost:8080/authors/webapp/test/flpSandbox.html?sap-ui-xx-viewCache=false#authors-tile
in the browser, the first thing that I get is the login pop-up.
Could you please advise on how to resolve the issue?
Attaching my project cap-java-ux-ui5-tooling-example.zip
Hi, this is due to the behaviour of your express app that you start manually. It doesn't know anything about the required authentication on CAP Java server-side. You either need to configure a hard-coded basic authentication in your server URL that you configure on your express application or you need to implement basic authentication in your express app and forward it to the backend.
In case you start the Spring Boot server and have the UI resources served by it, everything works out-of-the-box as the UI is authorized on the same URL as the server APIs and thus the browser can correctly handle the basic authentication for you.