Can't load environment variables from .env file

Hi, I am doing my web app using create-react-app and Auth0 for my login/logout functionality. However, I run into a problem when I have to load the domain and clientId from the .env file. I console log them and both of them are undefined. When I replace “process.env.REACT_APP_AUTH0_DOMAIN” and “process.env.REACT_APP_AUTH0_CLIENT_ID” with actual strings value, everything works.

Can anyone tell me why this happened and how to fix this kind of issue in order for it to use the .env file properly? Thank you

Hi @huynhnamdo,

Welcome to the Community!

In our react samples we use a json file for the configuration variable. You could try switching to this type of setup. Here is an example of the config file.

@dan.woda Thank you for your help

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.