A few ideas for you.
First, window.location.hostname
will return the browser-supplied hostname from the URL. You can also use window.location.href
if you wanted the entire URL for whatever reason. Using this, you could set your parameters like so.
// Running in development environment
if window.location.hostname = 'localhost' then
begin
...
end
// Running in production environment
else
begin
....
end;
Sometimes it is helpful to know where the application is running, globally. Perhaps you have more than one supporting server (XData for example) and you want to connect to the closest one. Or you have some kind of country-specific restrictions. You can try and get a bunch of this data from an
external source. Getting the local IP is non-trivial, but you can instead use something like this.
There's also the question about what data to supply for the alternate information. My habit of late has been to code the default values to point at the development environment and then supply a configuration.json file of some sort that overrides those to point at the production values. This configuration file is then loaded when the app starts.
For example, the JSON configuration would contain the server and port information for XData. When the app starts, it checks for this file. If it finds it, it uses that for the connection. If the file is not found, then it uses whatever the development environment defaults are. An example of what this might look like code-wise can be found in the Initialization section of this blog post.
The benefit here is that you can adjust the configuration JSON file to point wherever you like. Sometimes you might want the development code to point at a production server, for example, so you can just change the configuration, reload the page, and then be on your way.