This can be done if you use webpack to connect your client application using DefinePlugin, which allows you to create global constants that you can configure at compile time.
To achieve this, add something like the following to your webpack.config.js:
var constants = { 'webpack.constants.envVar1' : process.env.HEROKU_ENV_VAR_1, 'webpack.constants.envVar2' : process.env.HEROKU_ENV_VAR_2, ... }; module.exports = { ... plugins: [new webpack.DefinePlugin(constants),..], ... };
You can then reference your env vars Heroku anywhere in your AngularJS client application, for example.
doSomething(webpack.constants.envVar1);
However, the fact that this MAY be done does not necessarily mean that it MUST be done, at least not on Geroku. The reason it might be a great idea to do it on Heroku is because this circuit doesn't work very well with Heroku Pipelines .
Webpack needs to be run as part of the Heroku slug compilation , for example. in npm postinstall script .
Now, if you have a Heroku pipeline with, say, developers, middleware and production applications, and the deployment workflow is git, click on the development application and then push the pool to your production and then to your production applications, then BE MEAN that slug is ONLY created when you git click on your development application. Subsequently, it does not recover when it moves through the pipeline. This means that webpack ONLY starts once, and if you use the scheme described above to use env vars in your AngularJS application, the AngularJS client of your middleware and production applications will end using the env var Heroku values ββthat you assigned to your development application, which may not be what you wanted.