Environment variable undefined in test/syst/prod - Angular v12+Ocp4 config map

Viewed 31

I have Angular frontend and I need to access environment variable based on test, stage, prod. I have used this solution. Localy it picks up variable from .env file correctly, but when going through pipeline to test/stage/prod, variable from openshift config map is not picked up and is set to string "undefined" (process.env. vars work fine in backend though).

Any suggestions would be highly appreciated. Angular's default env files are not a viable solution for now, need a temp fix.

1 Answers

try to use this library. ng-process-env

It is based on angular schematics and allows you to replace values in your environment.config.ts file with relevant values from process.env

Related