menu
announcement

Spectrum is now read-only. Learn more about the decision in our official announcement.

Divjoy

The ⚛️ React codebase generator.

Channels
Team

incorrect .env vars for Firebase

April 18, 2020 at 11:46pm

incorrect .env vars for Firebase

April 18, 2020 at 11:46pm (Edited 2 years ago)
Hi Gabe, love the project! I ran into a small bug with naming conventions after export:
firebase.js (and analytics.js for GA) expect:
apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
however the .env vars are missing the REACT_APP prefix:
FIREBASE_API_KEY
FIREBASE_AUTH_DOMAIN
FIREBASE_PROJECT_ID
GOOGLE_ANALYTICS_TRACKING_ID
...resulting in null values in firebase.js and analytics.js when running locally
changing those to:
REACT_APP_FIREBASE_API_KEY
REACT_APP_FIREBASE_AUTH_DOMAIN
REACT_APP_FIREBASE_PROJECT_ID
REACT_APP_GOOGLE_ANALYTICS_TRACKING_ID
...resolves the issues. The vars are correct in .env.build. Thanks

April 19, 2020 at 4:28pm
Thanks for reporting this! Will get this fixed today.
Hey , so it should have worked without that change, since now dev makes the environment vars in .env.build available client-side. When running your project did you use now dev and if so could you tell me which version you have installed (with now -v)? Just want to get to the bottom of this to understand where the problem lies. Thanks!
Edited
Okay, I'm guessing you ran npm run start, which would explain why that change worked. Totally reasonable thing to do. I need to do a better job of directing users to use now dev, since that's required in order to have serverless functions in your /api directory run as well.
Edited

April 23, 2020 at 11:52pm
Sorry for the delayed response. You're right - I did run npm run start directly. I'm in the process of moving over to now dev. Thanks for the quick response!
like-fill
1