1

I want to share environment variables for my Node backend and my React frontend (create react app). I have followed below guide to set up the project.

https://medium.com/@chloechong.us/how-to-deploy-a-create-react-app-with-an-express-backend-to-heroku-32decfee6d18

Since my folder structure looks like below:

|project
|---.env <-- Want to use both for Node and React.
|---package.json <-- Node
|---client
|---|---package.json <-- React
|---|---src
|---|---|---index.js
|---|---|---app.js <-- Here I want to access .env in project root

The React app looks for it´s .env file in the client folder root but I want to specify the path for it uses the .env file in project root.

How can I specify the path in the React-frontend so it uses the .env file in project root?

Thanks in advance.

quieri
  • 345
  • 3
  • 19
  • Possible duplicate of [create react app not picking up .env files?](https://stackoverflow.com/questions/48378337/create-react-app-not-picking-up-env-files) – cullanrocks Sep 03 '19 at 19:40
  • 1
    The front end shouldn't have access to .env if I'm not mistaken. That's where all your database usernames and passwords and such live. – cullanrocks Sep 03 '19 at 19:42

0 Answers0