When I was building my web application I deployed it as two project a Webapi server and a Frontend using Angular. Anyways, for SEO and other consideration I used nodejs server to Server Side Rendering My Angular Application.
And lets say that
- my website public url is http://example.com
- my api are on port 5000: http://localhost:5000/api
- and Frontend are being served on port 5001: http://localhost:5001/home.
So when calling api on http://example.com/api from browser every thing is fine but my concern is when calling the api on SSR from nodejs server I will be using additional unnecessary traffic when I could just call the same api on http://localhost:5000/api.
My Question is
- in a situation like that and when I call an Endpoint which is located on the same machine using its public IP/DomainName Am I actually using additional traffic or the network is smart enough to fetch the data from the localhost?
- And when I call An Endpoint which is located on the same private network using it's public IP is it smart enough to use the private IP on the local network and therefore save unnecessary internet traffic?
- And if not? Are there Any Standard solutions/Patterns to solve this problem?