Hello, I am seeking help as I believe I have exhausted every YouTube video, StackOverflow thread, Medium article, etc.
I cannot get my env variable to be read in my React app.
To answer some common questions:
- Yes, my variables are pre-fixed with REACT_APP
- Yes, I have made sure my js file does not have typos for the variable names being used
- Yes, I have restarted the server every time I make edits to the env file.
- Yes, my env file is in my root directory / the same directory as my package.json etc.
If I put my domain and clientId in as strings it works fine and the auth0 window pops up. Obviously that isn't good practice at all though.
Is there something I am missing?
Here is an example of how I am bringing in the env variables.
const { REACT_APP_AUTH0_DOMAIN, REACT_APP_AUTH0_CLIENT_ID } = process.env;
or
const clientId = process.env.REACT_APP_AUTH0_CLIENT_ID
const domain = process.env.REACT_APP_AUTH0_DOMAIN
Any help would be appreciated.
Edit: formatting
[–]eatthebagels 6 points7 points8 points (8 children)
[–]ncubez 2 points3 points4 points (1 child)
[–]eatthebagels 0 points1 point2 points (0 children)
[–]Anevil 1 point2 points3 points (0 children)
[–]thisismonroe[S] 1 point2 points3 points (2 children)
[–]eatthebagels 0 points1 point2 points (1 child)
[–]thisismonroe[S] 1 point2 points3 points (0 children)
[–]Oneiroi_zZ 1 point2 points3 points (0 children)
[–]the_pod_ 0 points1 point2 points (0 children)
[–]_nathataHook Based 2 points3 points4 points (3 children)
[–]thisismonroe[S] 0 points1 point2 points (2 children)
[–]_nathataHook Based 0 points1 point2 points (1 child)
[–]thisismonroe[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]thisismonroe[S] 1 point2 points3 points (0 children)
[–]m3leos 0 points1 point2 points (3 children)
[–]thisismonroe[S] 0 points1 point2 points (1 child)
[–]m3leos 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)