Issue
process.env.VARIABLE_NAME
This does not work for some reason. It works in node after configuration the dotenv
library.
What do I need to do in the react side to make it work?
Solution
You can use dotenv
in React only for variables that start with REACT_APP_
.
So,
// index.js
require('dotenv').config();
console.log(process.env.REACT_APP_API_KEY) //works
console.log(process.env.DB_USER) //does not work
Answered By - cSharp Answer Checked By - Mary Flores (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.