Sunday, 19 March 2017

Using Heroku environment variables with angular-cli, deployed through Node server

I really like Django's implementation of using dotenv variables on Heroku and would like to bring it to our angular-cli client (Angular 2).

In order to run the client on Heroku I'm running the app through Node running express server.

  1. Node can access Heroku's env variables using process.env.VARNAME, but I didn't understand how to pass those variables to my app.
    How can I read Heroku's variables in my app?

  2. As far as I understand, when using angular-cli I should use environment.ts/environment.prod.ts files to separate environment settings.

    However, I don't want to upload these vars to Bitbucket - which brought me back to questioning how to set those variables from Heroku's vars (of course process.env.VARNAME doesn't work...)

Is that the recommended practice or am I missing something?



via Noam Gal

No comments:

Post a Comment