I have a react/node app that I\'m deploying. One of the components attempts to access NODE_ENV in order to determine which host URL to use (localhost or heroku).
I now r
It's a good practice to use NODE_ENV
variables for things like API URL.
If you used create-react-app, all environment variables starting with REACT_APP_
should already be accessible with process.env.REACT_APP_VARIABLE_NAME
.
You can try REACT_APP_TEST=5 npm start
then console.log(process.env.REACT_APP_TEST)
.
If you are not using create-react-app
, you have to import them in your webpack config.
You can also choose to define the process.env
variables for the app through a .env
file using dotenv.