In the era of cloud applications, a single project has multiple UI5 applications and multiple microservices. In this use case either we can have individual urls to access these or a single url that can act as an entry point. An approuter helps developers to get a single url to access all their apps and microservices. In this article we will learn more about AppRouter in SAP.
What is App Router in SAP?
SAP Cloud Foundry provides a nodeJs library in the form of BTP instance that acts as a single point-of-entry for an application or microservice running in the Cloud Foundry. It is known as Application Router or App Router or AppRouter.
We can perform following operations using App Router:
- Serve static data: The index.html file within App Router can be used to display static content or welcome page of an application
- Authenticate users: A user can be authenticated at approuter level, even before accessing any application
- Rewrite URLs: It can be used to integrate destination, integrate business services and even perform logout for an application
- Request to other microservices within same project
Types of App Router in SAP
SAP provides two types of approuter, they are:
1. Standalone Approuter
A standalone approuter is a custom approuter that is created and maintained by developer. A developer has to update the xs-app.json and MTA.yaml files according to the project needs.
2. SAP Managed Approuter
A SAP Managed Approuter enables a developer to execute HTML5 applications in SAP Cloud Platform. It is completely managed by SAP, hence you are not required to update any details further, once created.
To use managed application router, SAP provides three options:
- SAP Work Zone
- SAP Launchpad service
- SAP Cloud Portal
Once the application is deployed, the apps are available under the tab HTML5Repository within sub-account.
How to add Standalone Approuter using BAS?
To add a standalone approuter using BAS, follow the given steps:
Step 01: Create a MTA or CAPM Application such that your project has a MTA.yaml file.
Step 02: Right click on the MTA file and click “Open MTA Module from Template”
Step 03: Click “Approuter configuration” from the wizard
Step 04: Enter the details as shown below:
That’s it, an approuter will be added in your project with configuration in MTA file. Read more about it here.
How to add Managed Approuter using BAS?
The creation of SAP Managed approuter is almost similar to Standalone approuter until step 03.
In step 04, you need to choose “Managed Approuter” from the drop down, followed by a unique name for the approuter. That’s it, an approuter will be added in your project with configuration in MTA file. Read more about it here.
Once deployed, you can visit HTML5 Applications under your subaccount. In case you see the given screen:
In this case you need to subscribe any of the above, then you will be able to see your Applications as shown below: