cancel
Showing results for 
Search instead for 
Did you mean: 

Unexpected OData Service Request with Incorrect Path After Deploying AppRouter

Dipnesh
Explorer
0 Kudos
228

Hello SAP Community,

I have deployed a full-stack project on SAP BTP using Cloud Foundry, and everything is working fine with my AppRouter. After deployment, I received the following URL for my AppRouter:

Dipnesh_0-1729062999277.png

When I access this URL, it correctly redirects me to the welcome file (as specified in my AppRouter configuration), and my application (a SAP UI5 project) runs as expected. However, when inspecting the network traffic in the browser's console, I noticed that the app is attempting to fetch the following URL even though I haven't requested data from this service yet:

Dipnesh_1-1729063943615.png

 

Dipnesh_2-1729064137343.png

 

https://245509888trial-demo-fulldeploy.cfapps.us10000001.hana.ondemand.com/project125/odata/v4/library/

   project125 is the name of my UI5 application folder, which is inside the welcome file path in the                      AppRouter.

   library: is the base path for one of my OData services.

 

The issue is that this URL is returning a 404 status because the app seems to be appending the UI5 application path (project125) to the OData service URL (/odata/v4/library/), resulting in an incorrect URL: .../project125/odata/v4/library/.

My Questions are:

  1. Why is my AppRouter or UI5 app automatically appending the project125 path to the OData service URL when I haven't made any request to that service yet?
  2. How can I prevent the UI5 app from appending the project125 path to the service URL so that it fetches the correct path for the OData service?

 

 

this is my xs-app.json file  of my ui   project125.
 
 
{
  "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"
    }
  ]
}
 
 
 
 
THis is my approuter     xs-app.json file  :
 
{
"authenticationMethod": "route",
"logout": {
    "logoutEndpoint": "/app-logout",
    "logoutPage": "/"
},
  "routes": [
    {
      "source": "^/app/(.*)$",
      "target": "$1",
      "localDir": ".",
      "cacheControl": "no-cache, no-store, must-revalidate"
    },
    {
      "source": "^/user-api(.*)",
      "target": "$1",
      "service": "sap-approuter-userapi"
  },
    {
      "source": "^/appconfig/",
      "localDir": ".",
      "cacheControl": "no-cache, no-store, must-revalidate"
    },
    {
      "source": "^/(.*)$",
      "target": "$1",
      "destination": "srv-api",
      "csrfProtection": true,
      "authenticationType": "none"
    }
  ],
  "welcomeFile": "/project125"
}
 
Any solutions  or suggestions on how to resolve this would be greatly appreciated!
 
 
 

 

View Entire Topic
MioYasutake
Active Contributor
0 Kudos

@Dipnesh 

I think your approuter's xs-app.json should be like the one below. Please note that you have to put more restrictive route first in the routes array.

{
    "authenticationMethod": "route",
    "logout": {
        "logoutEndpoint": "/app-logout",
        "logoutPage": "/"
    },
    "routes": [
        {
            "source": "^/odata/(.*)$",
            "target": "/odata/$1",
            "destination": "srv-api",
            "csrfProtection": true,
            "authenticationType": "none"
        },
        {
            "source": "^/app/(.*)$",
            "target": "$1",
            "localDir": ".",
            "cacheControl": "no-cache, no-store, must-revalidate"
        },
        {
            "source": "^/user-api(.*)",
            "target": "$1",
            "service": "sap-approuter-userapi"
        },
        {
            "source": "^/appconfig/",
            "localDir": ".",
            "cacheControl": "no-cache, no-store, must-revalidate"
        }
    ],
    "welcomeFile": "/project125"
}