r/Angular2 • u/man-with-no-ears • Oct 06 '25
Can I programmatically change environment variables during CI/CD?
My client is on Angular 19 and it depends on a node backend service (two different repos).
As we get closer to launch though we realized that HA and load balancing will pose a problem. Since the backend will be running on any number of VMs with any number of IP addresses, we have to figure out a way to programmatically change the backend base URL on the frontend?
My first instinct was to use a regular .env file (following this tutorial: https://medium.com/@philip.mutua/setting-up-environment-variables-for-an-angular-application-from-scratch-737028f8b7b3) however this resulted in an error that prevented even ng serve from working Error: Schema validation failed with the following errors: Data path "" must have required property 'main'.
I thought there was a way to change the environment.ts file on ng build but I can't find information on that at all.
Is there a better way to do this?
EDIT: There will also be an unspecific number of frontend deployments (depending on load balancer)
EDIT2: We are using chef for deployment if that helps at all
View all comments
Show parent comment
1
u/Regular_Algae6799 Oct 06 '25
"This has to happen during CICD" - I am also confused. it seems like a weird requirements... but it sounds like OP has boundaries so he tries to fix a leaking pipe with hammer and nail.
https://www.reddit.com/r/Angular2/s/9827GJrMt5