Cancel
Showing results for 
Search instead for 
Did you mean: 

How to deal with application with multiple components + Developer Cockpit

Creator
Creator

Hi Team,

 

I have Mindsphere application which includes UI and backend as two deployed CF apps. Here in Mindsphere 3.0 we called them as two components.

 

After reading the documentation by Siemens team below:

https://documentation.mindsphere.io/resources/html/developer-cockpit/en-US/108954028811.html

 

I tried the application to registered as below but it is not working for me (Giving 403 forbidden error when UI tries to connect backend REST apis):

 

Steps followed:

1) Deployed backend service(restapi.war) in mindsphere CF (sample url: https://restapi-tenant.apps.eu1.mindsphere.io)

2) Change/Add the service url in UI code so that backend request goes to REST API on path : https://restapi-tenant.apps.eu1.mindsphere.io/

2) Deploy UI (ui.war) in mindsphere CF  (sample url: https://ui-tenant.apps.eu1.mindsphere.io)

3) Go to developer cockpit

4) Followed the steps given for creating new application here (https://documentation.mindsphere.io/resources/html/developer-cockpit/en-US/108768708747.html)

5) created application name as: "mytestapp"

6) Added two components , one for "ui" and other for backend service "restapi"

7) added endpoint "/**" for ui component

8) added endpoint "/*" for restapi (at least one endpoint is mandatory per component, also to be unique per application) - This point I am not sure what to give.

9) Saved

10) Added roles scope as per guideline ("mytestapp.all" for admin and user both) 

11) Registered the application

12) Added access from User management to myself

13) "mytestapp" is now visible in my dashboard (https://tenant-mytestapp-tenant.eu1.mindsphere.io/)

 

Now all I have is:

CF UI:                https://ui-tenant.apps.eu1.mindsphere.io

CF backend:      https://restapi-tenant.apps.eu1.mindsphere.io

Application:      https://tenant-mytestapp-tenant.eu1.mindsphere.io/

 

14) When I hit the application url("mytestapp") in browser, UI page shows error while getting the data from backend REST api

Error: Failed to load resource: the server responded with a status of 403 (Forbidden)

https://restapi-tenant.apps.eu1.mindsphere.io/mbp/getAllDashFactoryDetailsByProductionStageName/0%20-%20Initial/01-2018/04-2019

 

 

 

Did I misconfigure endpoints/components?

Did I miss to register restapi as separate application in Mindsphere?

Did i miss any role access?

 

Quick help will be appreciated.

Is anyone already tested end to end flow for multiple components?

 

Thanks

 

2 REPLIES 2

Re: How to deal with application with multiple components + Developer Cockpit

Siemens Genius Siemens Genius
Siemens Genius

Hi Nilesh,

 

my first guess was, its due to endpoint overlap. But, then it should have returned 404.

 

Can you maybe try and report the following:

 

What happens, if you remove UI components from application, and try to make GET call (the one that fails when made by UI) to your rest API using browser?

 

Outcome 1:

if the call succeeds, then its definitely url overlap issue. In this case, the solution is:

  1. You need to prefix endpoints with some basepath, for e.g. /testapis/<endpoints>
  2. Register restapi component with endpoint "/testapis/**"
  3. For UI component, make following changes
  4. Put all the UI resources (incl, index.html) under folder or path /home. Meaning, UI component will get loaded under path /home.
  5. Register UI component with endpoint "/home/**"
  6. Now, we have distinct endpoints for UI and backend components.
  7. Since, UI component and backend component are bundled together, UI component must invoke backend with relative path for e.g.

      /testapis/myResource.

 

 

Outcome 2

     Call fails. Then it is a permission issue and we need to get into details.

Re: How to deal with application with multiple components + Developer Cockpit

Creator
Creator

Thanks Michael.
Partially the same steps I have followed. It has resolved with below two changes in the configuration:


2) Change/Add the service url in UI code so that backend request goes to REST API on path : https://restapi-tenant.apps.eu1.mindsphere.io/

--- This was wrongly configured. So I changed to https://tenant-mytestapp-tenant.eu1.mindsphere.io/

8) added endpoint "/*" for restapi (at least one endpoint is mandatory per component, also to be unique per application) - This point I am not sure what to give.
--- This was wrongly configured. I have changed it to "/mbp/**"

Now the application is working fine.