Cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Call backend api hosted on MindSphere from UI app hosted on MindSphare - CORS Issues

Creator
Creator

At beginning, the HTML5 web javascript (Angular) running in a different application only used the external public address to directly call REST API of the common backend service running in another application.This was not working due to CORS issue.

In the second version using workaround solution with proxy app , the javascript was changed and is now using the frontend public address to call its own proxy app, which uses the internal address (e.g. from manifest/cf apps) to forward all frontend request to the common backend service in the other application. 

 

Re: Call backend api hosted on MindSphere from UI app hosted on MindSphare - CORS Issues

Legend
Legend
Ok, I understand your solution, and we tested both of those. Just wondering if you had tested (or could test easily) the scenario in which you just keep the backend app internal and forward your queries to the frontend app via the internal endpoint of the backend, not the external one. In this case I guess you would need to forward the authorization token to the backend, but probably wouldn't have any issues with cors.

It would be a bit like the Backends for Frontends design pattern (not that I specifically like that pattern).

Re: Call backend api hosted on MindSphere from UI app hosted on MindSphare - CORS Issues

Creator
Creator

No, I haven't tested yet such a scenario that you mentioned. For me it was not so clear how to configure the setup with internal and external endpoints that you mentioned and how to reuse one backend service from multiple frontend application. 

I've just read the chapter 7.3 in the developer cockpit user manual  (https://documentation.mindsphere.io/resources/html/developer-cockpit/en-US/index.html). Are your steps related to multiple components described there?

Re: Call backend api hosted on MindSphere from UI app hosted on MindSphare - CORS Issues

Legend
Legend
What is explained there is one way of doing it. It all depends on how you want to expose the app. In the most simple architecture, you just have a web static interface that interacts with a backend api server. You could actually deploy that with a single buildpack app that serves the static webapp and then offers an api. All is available in a single mdsp application that is externally reachable. You can configure (if you want), more refined patters of access in the Dev Cockpit rules, but it is a single app.

But from your description, I'm assuming that you have one backend application and then multiple frontend applications, each being its own buildpack mdsp application. In this case, your frontends might be simple static_buildpack apps and the backend implements the api. All must be externally reachable, and you could map all of them via subpaths in the DevCockpit with a single app (that's what's explained in 7.3 section of the user manual).

Or your frontends might actually be not only static web content, but also application logic. In this case you might want to "proxy" your queries to the backend via those frontends, and then you probably don't need to expose the backend externally.

It's all about choices :-)

Re: Call backend api hosted on MindSphere from UI app hosted on MindSphare - CORS Issues

Experimenter
Experimenter

@MichaelE wrote:

Hi @Dineshb,

 

thanks for your question. If I have understood your problem correctly, you basically want to make cross-application calls. Those kind of calls are currently not supported, by we are working on API-type applications.


 

Hi @MichaelE,

 

Any update of support the API-type applications?

 

thanks!

Re: Call backend api hosted on MindSphere from UI app hosted on MindSphare - CORS Issues

Siemens Genius Siemens Genius
Siemens Genius

@JoseA we are still working on this item.

Re: Call backend api hosted on MindSphere from UI app hosted on MindSphare - CORS Issues

Experimenter
Experimenter

@MichaelE wrote:

@JoseA we are still working on this item.


Hi @MichaelE

 

Thanks for you response, do you know the estimated date when it will be available?

 

Thanks in advance

Regards

Re: Call backend api hosted on MindSphere from UI app hosted on MindSphare - CORS Issues

Experimenter
Experimenter

Hi @MichaelE 

do we have any update if this feature is available?

 

Thanks

 

Re: Call backend api hosted on MindSphere from UI app hosted on MindSphare - CORS Issues

Experimenter
Experimenter

Hi,

is it possibile to use CORS on MindSphere? 

If not, is it possibile to create two apps (backend and frontend) and make them "communicate"?

 

Thank you,

Matteo

Re: Call backend api hosted on MindSphere from UI app hosted on MindSphare - CORS Issues

Creator
Creator

For me there was no way to get two apps working with each other because of the CORS issue. You will have 2 subdomains and this why you will fail because of CORS. Siemens provided no updates since 9 month.