I am new to SAP BTP and currently setup a simple project with a server and approuter on SAP CAP in nodejs. But when querying the approuter url from postman it gives me the following error:
Response:
<head>
<link rel="shortcut icon" href="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />
<script>
document.cookie="fragmentAfterLogin="+encodeURIComponent(location.hash)+";path=/";document.cookie="locationAfterLogin="+encodeURIComponent(location.href.split('#')[0].split(location.host)[1])+";path=/";document.cookie="signature=F1rQQvjwRIWe5DinMi%2FLRpgV4G0%3D;path=/";location="https://e517c145trial.authentication.us10.hana.ondemand.com/oauth/authorize?response_type=code&client_id=sb-modeloperativo1!t166096&redirect_uri=https%3A%2F%2Fe517c145trial-dev-modelooperativo-approuter.cfapps.us10-001.hana.ondemand.com%2Flogin%2Fcallback"
</script>
</head>
</html>
What I don't understand is that if I open the same url from the browser. Works correctly
What's more, if I test the Postman with the url of the server without using the approuter it works fine:
I have tried trying different configurations, but I can't find the error.
My main project files are the following: https://github.com/franciscobarra/ModeloOperativo/tree/main/ModeloOperativo
xs-security.json:
{
"xsappname": "modeloperativo1",
"tenant-mode": "dedicated",
"scopes": [
{
"name":"$XSAPPNAME.Callback",
"description":"With this scope set, the callbacks for subscribe, unsubscribe and getDependencies can be called.",
"grant-as-authority-to-apps":[
"$XSAPPNAME(application,sap-provisioning,tenant-onboarding)"
]
},
{
"name": "uaa.user",
"description": "UAA"
},
{
"name": "$XSAPPNAME.simple-approuter.admin",
"description": "Simple approuter administrator"
}
],
"attributes": [],
"role-templates": [
{
"name": "Token_Exchange",
"description": "UAA",
"scope-references": ["uaa.user"]
},
{
"name": "simple-approuter-admin",
"description": "Simple approuter administrator",
"scope-references": [
"$XSAPPNAME.simple-approuter.admin"
]
}
],
"oauth2-configuration": {
"credential-types": [
"binding-secret",
"x509"
],
"redirect-uris": [
"https://*.cfapps.us10-001.hana.ondemand.com/**",
"https://*.applicationstudio.cloud.sap/**",
"https://*.us10-001.hana.ondemand.com/login/callback"
]
}
}
xs-app.json:
{
"authenticationMethod": "route",
"logout": {
"logoutEndpoint": "/app-logout"
},
"routes": [
{
"source": "^/user-api(.*)",
"target": "$1",
"service": "sap-approuter-userapi"
},
{
"source": "^/(.*)$",
"target": "$1",
"destination": "srv-api",
"csrfProtection": true,
"authenticationType": "xsuaa"
}
]
}
mta.yaml:
_schema-version: '3.1'
ID: ModeloOperativo
version: 1.0.0
description: "A simple CAP project."
parameters:
enable-parallel-deployments: true
build-parameters:
modules:
- name: ModeloOperativo-srv
type: nodejs
path: gen/srv
parameters:
buildpack: nodejs_buildpack
build-parameters:
builder: npm
provides:
- name: srv-api # required by consumers of CAP services (e.g. approuter)
properties:
srv-url: ${default-url}
requires:
- name: ModeloOperativo-db
- name: ModeloOperativo-auth
- name: ModeloOperativo-destination-service
- name: ModeloOperativo-connectivity-service
- name: ModeloOperativo-approuter
- name: ModeloOperativo-db-deployer
type: hdb
path: db
parameters:
buildpack: nodejs_buildpack
requires:
- name: ModeloOperativo-db
- name: ModeloOperativo-approuter
properties:
NODE_DEBUG: 'xssec,passport,http,https'
type: approuter.nodejs
path: app/ # from cds.env.folders. Consider also cds.env.build.target -> gen/app
parameters:
keep-existing-routes: true
disk-quota: 256M
memory: 256M
requires:
- name: srv-api
group: destinations
properties:
name: srv-api # must be used in xs-app.json as well
url: ~{srv-url}
forwardAuthToken: true
- name: ModeloOperativo-auth
- name: ModeloOperativo-srv
- name: ModeloOperativo-destination-service
- name: ModeloOperativo-connectivity-service
- name: ModeloOperativo-logging
resources:
- name: ModeloOperativo-db
type: com.sap.xs.hdi-container
parameters:
service: hana
service-plan: hdi-shared
- name: ModeloOperativo-auth
type: org.cloudfoundry.managed-service
parameters:
service: xsuaa
service-key:
name: key-xsuaa
service-plan: application
path: ./xs-security.json
config:
xsappname: modeloperativo1
tenant-mode: dedicated
- name: ModeloOperativo-connectivity-service
parameters:
service-plan: lite
service: connectivity
- name: ModeloOperativo-destination-service
parameters:
service-plan: lite
service: destination
type: org.cloudfoundry.managed-service
- name: ModeloOperativo-uaa-apiaccess
type: org.cloudfoundry.managed-service
parameters:
service: xsuaa
service-plan: apiaccess
- name: ModeloOperativo-logging
type: org.cloudfoundry.managed-service
parameters:
service: application-logs
service-plan: lite
Application: ModeloOperativo-approuter - Service Bindings:
RoleCollection - Scopes - User:
I would appreciate your help. Thank you so much




