btw quick tip to improve your privacy: to make this less accurate and make fingerprinting you harder, you can use a vpn. I recommend using proton vpn, which has a free plan with unlimited data, or cloudflare warp, which even though doesn’t let you choose a country is pretty fast and can sometimes make it less accurate.
any server has access to your IP address, even without doing anything on the client-side. I’m guessing miles used ipapi to not need to set up his own server.
The database they use to geolocate your IP is never going to be 100% accurate and while services like maxmind try to make it as accurate as possible there are still a a bunch of technical limitations and privacy concerns