How to get the Http Request response before rendering - Angular Universal

I am using Angular Universal for SSR. I want to hide the Http Request being sent from the Browser and send it from the Server. I have been trying all the possible ways but nothing is working. I got universal-starter repo from Angular and started working on it. This is the repo link with my changes - https://github.com/GowthamF/sample-universal . Hope someone can help me with this. I have been trying this for like six months.

enter image description here

enter image description here

Upvotes: 0

Views: 542

Answers (2)

Lashan Fernando
Lashan Fernando

Reputation: 1255

For server side you need full url

in your case HomeComponent.ts

this.heroesUrl = 'http://localhost:4000/api/Country/GetCountires'

better to implement a interceptor for your case

I just tried this dummy call, it works for me

this.heroesUrl = 'https://jsonplaceholder.typicode.com/users'

Upvotes: 1

R.K
R.K

Reputation: 197

You cant hide the user from seeing what he's doing on his own browser.

What you can do is send a token with an expiration date and only allow the request token once or more, so if some 1 wish to send that request again and again it wont be accepted.

If you final goal is to send the main request from your server, you must send a request to the server which will send main request.

Upvotes: 0

Related Questions