My Gatsby app hosted on Netlify is throwing an error concerning my Firebase config.
What's the proper syntax for keying my app into Firebase via Netlify & Gatsby ?
My config is at the top of my src/components/Firebase/firebase.js:
const config = {
apiKey: process.env.API_KEY,
authDomain: process.env.AUTH_DOMAIN,
databaseURL: process.env.DATABASE_URL,
projectId: process.env.PROJECT_ID,
storageBucket: process.env.STORAGE_BUCKET,
messagingSenderId: process.env.MESSAGING_SENDER_ID
};
Locally, at the top of my gatsby-config.js:
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`,
})
On Github, I'm omitting the require statement in my gatsby-config.js because Netlify has a copy.
Yet, I'm getting is an error both local and Netlify:
Uncaught (in promise) code: "auth/invalid-api-key"
message: "Your API key is invalid, please check you have copied it
correctly.
Yep, I checked, my env vars are fine..
I thought this would be straight forward. My app ought to have access to the config data based on the fact that Netlify has a copy.
Playing around I saw yy app works locally and on Netlify if I pass the sensitive firebase config directly via firebase.js. But, Obviously that's a no-no.
Anyone else experience similar results in getting a similar setup to work?