So Astro does provide a global of Astro.url which is a readonly property of the request location. It also has Astro.site , but you'll have had to set that in your Astro config for it to pick it up.
Afaik, this isn't a problem of it "doing harm" or not being accessible, it's that the server fundamentally does not contain that information. All a server knows is what port to listen on, and because you can access your server through many different ways (localhost, 127.0.0.1, 0.0.0.0, or any other custom host name you've set up on your machine), the server has literally no idea which one you'll be accessing it on. It has no outside knowledge of www IP or hostname. It'd be like trying to call your own mobile phone, but you don't know what your number is - it may as well be impossible.
It's also worth noting that the Vite server runs in development too, your live server will be out of Vite-land.
As soon as you're looking at dynamic addresses, hosts or domains or anything, your solutions complexity is going to increase massively. I'm sure there'll be some clever way of doing through through docker, but I'm not exactly sure what it'll be. But it will involve setting an environment variable of the machine's address.
So just to double check, you have an Astro server hosted at say https://[dynamic-name].mydomain.com , for example, and you want the server to be able to request remote images from itself, and have knowledge of that url you're pointing at it?