Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set Heroku config vars programmatically from inside the app running on Heroku?

Tags:

heroku

I have an app running on Heroku with a small handful of settings that I want to change from time to time, and I'd like to use Heroku config vars to store these settings so they persist durably.

I know I can modify the settings from the Heroku dashboard or the Heroku CLI, but I'd like to modify them from within the app UI.

I can't seem to figure out how to modify the app's Heroku config from within the app code. If I simply modify the dyno's environment, for example, those changes do not persist to the app's config.

like image 630
rossmeissl Avatar asked Sep 02 '16 17:09

rossmeissl


People also ask

How does Heroku config vars work?

Whenever you set or remove a config var using any method, your app is restarted and a new release is created. Config var values are persistent–they remain in place across deploys and app restarts. Unless you need to change a value, you only need to set it once.

How do you change environment variables in Heroku?

The first step is to log into your account and go to the Heroku dashboard. Figure 1 illustrates my dashboard. Choose the application for which you want to set the environment variables. Once you select the application, it takes you to the overview page of that project.

How do I use Heroku config vars in node JS?

You want to use heroku config:set IP=http://app.mydomain.com ; it defines an environment variable called IP , which you access in Node. js via process. env. IP .


1 Answers

You can use Heroku Platform API for this. Especially this part. There is also a ruby client

like image 176
Michał Młoźniak Avatar answered Nov 02 '22 00:11

Michał Młoźniak