Download Community Commons Functions Library from the app store and you can use “GetApplicationUrl “ function in it.
It will return your app url and I think adding decision on it you can do further actions based on where app is running.
You can also take a look at the Mendix Core Class in API. It can be used from a java action in a microflow.
I think the preferred way here is to use constants (see the documentation here https://docs.mendix.com/refguide/constants). You can define a constant in your application, use it inside your microflows and re-assign it via deployment configuration on your environments.
The shortcut is using Umar's tip: "GetApplicationUrl”. To have some more control, I created a module for that about a year ago: Environment variables DTAP. Have a look, it might be helpful.