How could do some http requests just from the server side in Angular Universal

2.1k views Asked by At

I'm implementing Angular Universal over an Angular project to hide some http requests, but in my research, I found that I can't hide those with the way provided by Angular. Did someone try to do the http request in the express engine an retrieve the data?

The target is a very large Angular 5 project (I know.. If I wanted to do the http requests from the server, I wouldn't use Angular but I didn't begin the project)

I applied the configuration recommended by Angular in this article: https://angular.io/guide/universal

I want to hide some requests from the client

2

There are 2 answers

0
David On BEST ANSWER

You cannot. Only initial page will be rendered using angular universal; once that page is loaded the client side angular application takes over and then you've got SPA navigation, with ajax calls to your API.

0
Craig On

You can make the HTTP calls server side and then send that state through with your page using the TransferHTTP library.

https://medium.com/@alireza.mirian/reusing-server-side-http-responses-in-front-end-when-using-ssr-in-angular-970d3efaea59