I am currently creating an angular application that uses a REST API
to send and receive calls from an instance at the backend. Currently, this URL is defined as an environment variable as below:
export const environment = {
production: false,
loggerLevel: NgxLoggerLevel.DEBUG,
disableConsoleLogging: false,
lang: 'en',
api: {
. //other variables
.
.
host: "http://mycoolurl.com/rest/v11_1/",
.
. //more variables
.
}
};
Now, there is a similar question that addresses this issue here but even that uses a specific settings.json file that would be fetched using APP INITIALIZER
. Another similar question here also suggested me to use a separate JSON file.
A recent requirement change stated that the user should be able to specify the URL that he wants to send the REST
calls to, so preferably it would be an input field that he would be entering the URL into and it would update the host in the environment file. How do I achieve this?
Unfortunately, I cannot change the entire implementation and remove the host from the environment, it is being imported and used in so many places throughout the application.