In my Angular project, I have set up multiple environments for different stages of development, testing, acceptance, and production. Each environment has a specific base URL, which I designate using the --base-href flag during the project build. However, I also need to connect to a second web server that also has its own set of DTAP stages. I am looking for a way to automatically determine which base URL flag is set so that I can assign the corresponding URL for the second web server in my code.
Despite my efforts to find information on this topic, I have not been successful in achieving the desired outcome. Currently, I manually update the variable value, but I want to eliminate this step as it is prone to oversight during project builds.
My goal is to implement the following code:
let url;
if (base-href.contains('test'))
url = 'https://test.com';
else if (base-href.contains('acceptance'))
url = 'https://acceptance.com'
else if (base-href.contains('deployment'))
url = 'https://deployment.com'
// Send API call to URL
The URLs I use for building are consistent, allowing me to predict their content and ensure correct assignment of the second web server URL.
If anyone can provide guidance on how to achieve this functionality, I would greatly appreciate it!