I have defined a config var "BASE_URL" in my Heroku app and I'm trying to access it in my React app as
process.env.BASE_URL
but it gives me undefined when I console.log it as it seems to be not existing. How can I access Heroku config vars in my React app?
You have to use a module that loads environment variables. Then,
require('dotenv').config()
...
console.log(process.env.BASE_URL);
Check this post, pretty useful.