cancel
Showing results for 
Search instead for 
Did you mean: 

Standalone App Router redirection Cloud Foundry

pascal_renner
Explorer
0 Kudos
618

Hello,

I want to configure the stanalone app as following:

    {
"source": "/test/(.*)$",
"target": "/<appID>/$1",
"service": "html5-apps-repo-rt",
"authenticationType": "none"
}

/test/index.html is supposed to redirect to /<appID>/index.html. The index.html file actually loads but loading the sap-ui-core.js results in a 404 error. The path for the sap-ui-core.js requested by the client is /test/resources/sap-ui-core.js

Loading from /<appID>/resources/sap-ui-core.js works fine.

Here is the xs-app.json of the UI5 project:

{
"welcomeFile": "/index.html",
"authenticationMethod": "route",
"routes": [
{
"source": ".*/resources/(.*)$",
"target": "/resources/$1",
"authenticationType": "none",
"destination": "ui5"
},
{
"source": "^.*/test-resources/(.*)$",
"target": "/test-resources/$1",
"authenticationType": "none",
"destination": "ui5"
},
{
"source": "^(.*)$",
"target": "$1",
"service": "html5-apps-repo-rt",
"authenticationType": "none"
}
]
}

Any idea?

Accepted Solutions (0)

Answers (1)

Answers (1)

WouterLemaire
SAP Mentor
SAP Mentor

Hi,

I did something similar where I wanted to redirect the root path to an app. This is the config I used:

{
    "authenticationMethod": "none",
    "welcomeFile": "/index.html",
    "routes": [
      {
        "authenticationType": "none",
        "csrfProtection": false,
        "source": "^/odata/",
        "destination": "my-api"
      },
      {
        "source": "^/resources/(.*)$",
        "target": "/resources/$1",
        "authenticationType": "none",
        "destination": "ui5"
      },
      {
        "source": "^/test-resources/(.*)$",
        "target": "/test-resources/$1",
        "authenticationType": "none",
        "destination": "ui5"
      },
      {
        "source": "^(.*)$",
        "target": "/mayappnamespace/$1",
        "service": "html5-apps-repo-rt",
        "authenticationType": "none"
      }]
  }

 

To adapt this for your scenario, I think you can do something like this:

{
    "authenticationMethod": "none",
    "welcomeFile": "/index.html",
    "routes": [
      {
        "authenticationType": "none",
        "csrfProtection": false,
        "source": "^/odata/",
        "destination": "my-api"
      },
      {
        "source": "^/test/resources/(.*)$",
        "target": "/resources/$1",
        "authenticationType": "none",
        "destination": "ui5"
      },
      {
        "source": "^/test/test-resources/(.*)$",
        "target": "/test-resources/$1",
        "authenticationType": "none",
        "destination": "ui5"
      },
      {
        "source": "^/test/(.*)$",
        "target": "/<appid>/$1",
        "service": "html5-apps-repo-rt",
        "authenticationType": "none"
      }]
  }

I'm not completely sure that "/test" in front of resources is needed, give it a try with and without 🙂

This will also requires the approuter to have access to the ui5 destination. Therefore, you need to add the following config in the mta.yaml for the approuter module:

  - name: approuter
    type: approuter.nodejs
    path: approuter
    requires:
    - name: auth
    - name: connectivity
    - name: html_repo_runtime
    - name: destination
      group: destinations
      properties:
        forwardAuthToken: false
        name: ui5
        url: https://ui5.sap.com

 

An alternative solution could be to just point to https://ui5.sap.com in your index.html page.

 

pascal_renner
Explorer
0 Kudos
Thank you, that works! I'm a little confused because /<appID>/index.html still works altought it isn't configured (I configured it as your 2nd code block). Do you have any idea why it still goes through?