I have an Angular 2 app that will be installed on multiple servers, and needs to access a backend that is also on multiple servers. I'm using the code from this answer, specifically the edit that works with methods other than GET, and it works well if I hardcode the backend URL.
For a given frontend server, the backend it needs to access will always be the same. For example, if the frontend is on "example.com", the backend will always be on "example.com:9080".
I can bundle the app for each different server, changing "localhost:9080" in that answer to "example1.com:9080", "example2.com:9080", etc. as appropriate. This would mean having to make code changes and bundle the app for each server.
Is there a way that I can somehow fetch the URL that I need to access for the backend so I can bundle it once and deploy it to all the servers?
I'm using Angular 2.4.5 and serving the frontend using Apache.