Reputation: 42267
I've run into a situation where the app I'm developing needs to determine if its running on Heroku or locally. (Side note, but Imagemagick on Heroku doesn't seem to respect the -format option, so the result that comes back is different than local dev. Not entirely relevant to the question).
Are there any native environment variables on Heroku that can be used by the app to determine this?
I've done a fair bit of searching and reading through Heroku's docs, but I'm not finding any info on this.
Thanks!
Upvotes: 3
Views: 459
Reputation: 19973
There are any number of heuristics you could use to determine whether you're running on Heroku with reasonable accuracy, but they're mostly hacks (look at the directory structure, etc). I'm not aware of any simple "this is Heroku" environment variable provided by the system.
The "correct" thing to do in this situation is to actually determine what the functional differences that are relevant to your application are and then test for those specifically. For instance, if your concern is entirely that Imagemagick works differently, then you should find out why it works differently and test for that (is a required library missing? Is Heroku using a different version? etc.) That way even if you deploy to another host that is not Heroku but has the same problem, your app will recognize that.
If this is not an option, you can always set any environment variable you like using heroku config
.
Upvotes: 3