Please put me out of my misery. I see scores of other people had the same issue and I don't see a solution.
I am trying to put my sensitive keys into environment-specific files (.env.development, .env.staging, etc). The keys work fine if I put them in .env but I need this file for some other items which must be pushed up to source control. All of the files are in root (I see that this was a common mistake). Is there something with webpack that is the issue? I have restarted the server instance every time I make a change.
const express = require('express');
const path = require('path');
const app = express();
require('dotenv').config();
console.log('ENV', process.env.NODE_ENV); // this returns "development"
console.log('Hello?', process.env.REACT_APP_HELLO); // this returns "undefined"
As noted I am surfacing the environment correctly.
"start": "SET NODE_ENV=development&& node server/index.js",
from package.json
REACT_APP_HELLO=BLAH
from .env.development