Is there some variable or function I can call to know if a node.js application is running inside Heroku? Something like:
if (process.heroku)
console.log("I'm in Heroku!");
You can do this without setting custom environment variables. You can do it like this:
if (process.env._ && process.env._.indexOf("heroku") !== -1)
console.log("I'm in Heroku!");
This is possible because on a Heroku dyno the _
environment variable is set to /app/.heroku/node/bin/node
.