You will now create a basic web module. This module is very important as it will become the entry point for your application. Every request coming to this module will be routed into the different backend services.
Right-click on the project folder and choose New > Basic HTML5 Module (or just New > HTML5 Module if using the SAP Web IDE Full-stack).
If using the SAP Web IDE Full-stack there will be a question here asking for template selection. Please choose SAPUI5 Application.
Call it web
and click Finish.
Since the web module will be receiving the requests and routing them into the proper processing backend services, such as the OData service you have just defined, it will also be responsible for enforcing authentication.
These routing logics are done by an application called approuter
. You can see the Node.js module being called as the starting script for the web module as defined in the file package.json
.
The approuter
will scan the file xs-app.json
to route patterns in the request to the right destinations.
Replace the content of xs-app.json
with the following content if you are using SAP Web IDE for SAP HANA:
{
"welcomeFile": "index.html",
"authenticationMethod": "none",
"routes": [{
"source": "/catalog/(.*)",
"destination": "srv_api",
"csrfProtection": true
}]
}
If you are using the SAP Web IDE Full-stack, use this code instead:
{
"welcomeFile": "index.html",
"authenticationMethod": "none",
"routes": [{
"source": "/catalog/(.*)",
"destination": "srv_api",
"csrfProtection": true
},
{
"source": "^/web/(.*)$",
"target": "$1",
"localDir": "webapp"
}]
}
Save the changes.
Among other information, this configuration is declaring that requests containing the pattern /catalog/(.*)
are routed to a destination called srv_api
.
This destination can be defined in the mta.yaml
file.