I was able to create a solution that works for all manner of local development as well as production releases.
I created some JavaScript, apiurl.js
, that sits alongside all of our other JavaScript content. If the apiurl.js
file is present, I read its responseText
into eval()
. The frontend can therefore change the URL based on the content of that file.
E.g., apiurl.js
has:
var apiurl = "https://staging-server.somewhere.com";
And the JavaScript to handle the content:
eval(responseText);
if (typeof(apiurl) != undefined) {
url = apiurl;
}
The apiurl.js
file is untracked by version control and not used in production.