Checking the HA instance url to perform actions

Hi there,
I put it simple, is there any way to check what url the home assistant instance where an action is perform (button pressed, switch toggled etc) and perform a certain action if it is using the internal url and another one if it is using the external url?

Thank you for any support you might be able to offer.