How to distinguish that app is running on local or external address

Hi,

because of my poor network I need to distinguish that HA is running on local or external address so I can display camera image in picture-entity card when running externally and live view go2rtc card when running locally. I need to do that especially for android companion app. Thanks for any tip!