Check if your code is running on Heroku
npm install is-heroku
import isHeroku from 'is-heroku';
// On your local computer
console.log(isHeroku);
//=> false
// On Heroku
console.log(isHeroku);
//=> true
Add an environment variable first to improve the detection:
heroku config:set HEROKU=1