Hardcoding in this or another way an address to the API server is not a good way.
The API URL should be stored in a configuration file possible to change without recompiling whole application. I think this is a way you should do it: Editable config file