Run SAP App Router Locally
This is a summary after testing SAP App Router locally. Running SAP App Router locally may be not necessary for most cases, thus this is to demonstrate the technical possibility.
Actually there are some famous blogs about this topic, hence I don't want to repeat those basic steps again here. What I want to highlight here are issues I met during my test. For basic setup steps you can search for relevant posts.
BTP Service and App
For my test, I followed this public tutorial to setup BTP apps and service in my trial account. But one important point which is missed in the tutorial is additional settings for XSUAA service configuration. In order to do authentication from local app router against remote BTP XSUAA service, below configuration is necessary. Otherwise, we will get invalid call back during oAuth authentication flow.
"oauth2-configuration": {
"redirect-uris": [
"https://approuter-product-list-ap25-xxx.cfapps.us10-001.hana.ondemand.com/login/callback",
"http://localhost:9527/login/callback",
"http://localhost:9527/products/login/callback"
]
}
The first url is for app router running in BTP. The 2nd and 3rd urls are for app router running in local desktop. It seems that XSUAA only checks this configuration in newer versions. In older versions, there is no such error raised even no URl is configured.
Local xs-app.json Configuration
When running the app router locally, the ideal scenario is, I access my local address http://localhost:9527, if no authenticaltion has been made, it triggers the oAuth2 authenciation flow per the default-env(VCAP_SERVICES) configuration. After a successful authentication, page is redirected to the index.html. The index file locates at /myapp/static/index.html. Then I have xs-app router as below:
{
"source": "^/(.*)",
"target": "index.html",
"localDir": "./myapp/static/",
"authenticationType": "xsuaa"
}
It means, when default address is accessed, it will be redirect to target+localDir. In this case, it will be redirected to ./myapp/static/index.html. Since the authenticationType is xsuaa, app router will triggers oAuth2 authentication automatically. The SAPUI5 app requests data from remote BTP service, thus I need below router in order to route data request to remote BTP.
{
"source": "^/products",
"target": "/products",
"destination": "products-destination",
"authenticationType": "xsuaa"
}
Local default-env.json Configuration
The remote destination for requesting remote data.
{
"name": "products-destination",
"url": "https://product-list-ap25-xxx.cfapps.us10-001.hana.ondemand.com",
"forwardAuthToken": true
}
Remote XUSAA instance information.
"VCAP_SERVICES": {
"xsuaa": [
{
"tags": [
"xsuaa"
],
"credentials": {
"apiurl": "https://api.authentication.us10.hana.ondemand.com",
"clientid": "sb-product-list!t164751",
"verificationkey": "",
"clientsecret": "",
"identityzone": "",
"identityzoneid": "",
"sburl": "https://internal-xsuaa.authentication.us10.hana.ondemand.com",
"tenantid": "",
"tenantmode": "dedicated",
"uaadomain": "authentication.us10.hana.ondemand.com",
"url": "https://trial.authentication.us10.hana.ondemand.com",
"xsappname": "product-list!t164751"
}
}
]
}
Comments
Post a Comment