Search code examples
reactjsherokuenvironment-variablesdotenv

Heroku environment variables unvisible in React app despite using dotenv


I have my heroku variables set like that:

enter image description here

(MODE is inserted because I thought that NODE_ENV may be getting overwritten)

In my React app I do this:

import dotenv from 'dotenv';

dotenv.config();
console.log(process.env)

But in my console (under the heroku URL of course) I see only:

enter image description here

What am I doing wrong?


Solution

  • Okay, the solution was changing the name of KEY to REACT_APP_KEY and restarting all dynos - we can do this here:

    enter image description here