Link to home
Start Free TrialLog in
Avatar of ank5
ank5Flag for India

asked on

Angular app deployed on cloud - call REST services from browser

We are planning to build a angular app that needs to be hosted on the cloud. Customers can simply subscribe to it as they would to any SAAS application.

This application will talk to the customer database/document repository which is hosted on premise. In order to make this communication happen there would be a bunch of REST services that the customer would deploy on premise. These REST services will be able to establish a connection with the Database and perform necessary actions.

The architecture that I was thinking of initially was to have the Angular app establish a connection to the REST services. Below is the diagram

  User generated image
However, this has challenges with establishing a secure connection between the cloud application and the REST services deployed on premise. Most customers will not allow external applications to connect to one of the server ports.

So, I was suggested that instead of having the connection from the application server on cloud, I should consider having a browser make a connection to the REST service. Since user would be on the internal network it would not need any firewall ports to be opened etc.

User generated image
Can someone please help me understand how this can be done? Will the angular app provide a REST url to the browser and then browser will use that URL to get data from the REST service? Are there any examples that I can refer to?
Avatar of BigRat
BigRat
Flag of France image

An Angular " App" runs ENTIRELY in the browser. The code (html, Javascript, images) for the app will come from an HTTP server which may reside in the "cloud".

A REST service is just a set of HTTP calls from the browser to a REST server which may or may not be the same HTTP server as the HTTP server which serves up the App.

If you want the browser to talk to only one server (ie: no cross domain issues) then you'll need a proxy on the HTTP server to pass the requests onwards to the database server. The best and simplest way of achieving is to use Node Express.

You can get Node Express to do two things - serve up the HTML, Javascript and Images like an HTTP server (no need for Apache) and pass on the data requests to the database server. On the other hand Apache is very good at serving up images, script and HTML, so one just proxy forwards REST calls to Node (Rewrite rule). If there are any issues of authentication (login and the like) then use the Passport module with Node Express. Furthermore you can do all the sort of URL rewriting in Node, which in this way the database server remains just what it is - a database server.

Just Google Node Express, Passport for further details.
Avatar of ank5

ASKER

Thank you. Where will the Node Express sit? Will it be in the cloud or the customer environment? Will Node Express be in addition to the two application servers (one of cloud for angular and another on premise for REST) or does it replace one of them?
ASKER CERTIFIED SOLUTION
Avatar of BigRat
BigRat
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial