Heroku sets SECRET_KEY_BASE when it's not defined

Viewed 182

I want Heroku to not set SECRET_KEY_BASE so I can use the one from credentials, but despite me deleting it from the UI, verifying it doesn't exist by running heroku config, I still get it set as an environment variable on my dynos. And it's the same in all the dynos:

SECRET_KEY_BASE=d2753b472abb...

I also tried setting it to a blank string by running heroku config:set SECRET_KEY_BASE="" and Heroku insist on setting it up as I can see by running bash and then env within bash.

How can I prevent that from happening?

1 Answers

Unfortunately, the Heroku Ruby buildpack generates and sets SECRET_KEY_BASE via the shell if it doesn't exist in your Heroku config vars.

It currently doesn't seem possible to directly use the secret key set in credentials.yml. You could make credentials.yml and SECRET_KEY_BASE align though.

Source: https://github.com/heroku/heroku-buildpack-ruby/issues/1143

And here is a short extract from that issue:

  • If you set your own SECRET_KEY_BASE, we do nothing.
  • If you do not set a SECRET_KEY_BASE we generate and set one for you.
  • We recommend using our heroku config interface for storing secrets rather than using the encrypted file storage that ships with rails.
  • If you want to use encrypted file storage locally with rails you could copy our secret key base heroku run echo $SECRET_KEY_BASE or you can set your own value manually locally and then again via heroku config.
Related