I’m working with Angular 18 and need to retrieve the client’s IP address during both server-side rendering (SSR) and client-side rendering. I’ve come across this answer on how to achieve this with Angular Universal, but Angular 18 no longer uses Angular Universal for SSR.
The approach in the answer involves checking the platform (SSR vs client) and handling the IP retrieval manually, which feels cumbersome and redundant. Is there a more seamless or efficient way to fetch the client’s IP address without having to constantly check the current platform? I imagine this can be achieved with ValueProvider but I struggled to find an example.
Ideally, I’m looking for a solution that works across both SSR and client runtime without duplicating code or adding unnecessary complexity.