At the time of compilation, you don’t have access to process.env, and it is available to node application where it is not available for angular application.
Other ways to resolve the issue:
1. Make a task in your build pipeline to update the environment file with the correct value.
If it needed to be dynamic.
2. Just hard-code it and make several environmental files to match each of your environments. You can specify your environments in your angular-cli.json.
I think option 2 will help you to solve your problem, for that you need to put this in your angular-cli.json for that use
And build your app with ng build --env=prod.
For further query refer: https://alligator.io/angular/environment-variables/