Replace all the hostname in all api calls from one glabal variable

Dear,

How shall I dynamically put the hostname in the URL?

I change the hostname often and do not want to change all the API call’s URLs every time. Any suggestions?

Example:

declare variable

hostname = ec2-18-222-1888-75.us-east-2.compute.amazonaws.com

I want to use URL like this :

http://{hostname}:8080/uem/all/posts

{hostname} shall be replaced by the value of the variable and the final URL shall become like this :

http://ec2-18-222-1888-75.us-east-2.compute.amazonaws.com:8080/uem/all/posts

Are you getting the challenge here?

Regards,
Gagan