nuxt-firebase-auth icon indicating copy to clipboard operation
nuxt-firebase-auth copied to clipboard

Extracting Firebase config into environment variables

Open CanyonTurtle opened this issue 7 years ago • 5 comments
trafficstars

I am very fond of this project by the way.

Is there a specific reason that services/fireinit.js doesn't use the .env variables? It seems like the firebase config object could use process.env.API_KEY and so forth as values instead of the copied string literals that will be the same as in the .env file already.

It would look something like this:


// services/fireinit.js

var config = {
  apiKey: process.env.API_KEY,
  authDomain: process.env.AUTH_DOMAIN,
  databaseURL: process.env.DB_URL,
  projectId: process.env.PROJECT_ID,
  storageBucket: process.env.STORAGE_BUCKET,
  messagingSenderId: process.env.MESSAGING_SENDER_ID
}

I used @nuxtjs/dotenv to facilitate using .env for this on a side project. I'm not sure what happens on the Firebase console side as far as configuring environment variables, but I was able to get a working project deployed on Firebase hosting myself without any extra effort besides setting up the aforementioned. I know Netlify, a similar service to Firebase hosting, offers environment variable configuration and I am sure there must be a similar solution for Firebase and other hosting services.

I could make a PR if you are interested!

Again, awesome project!

CanyonTurtle avatar Dec 04 '17 07:12 CanyonTurtle

I'm with the same problem...

DaviRolim avatar Apr 11 '18 12:04 DaviRolim

Problem still here in 2019

rorp24 avatar Sep 05 '19 13:09 rorp24

Problem still here in 2020, simply nuxt is just a mess in terms of security, it exposes everything what's possible and there is no proper explanation how to get rid of this problem.

paulvonber avatar Jan 19 '20 14:01 paulvonber

The problem still persists in 2021, I really need the right way of doing it

Abel-Moremi avatar Aug 04 '21 01:08 Abel-Moremi

Problem still here in 2022

yarliganfatih avatar Jul 02 '22 13:07 yarliganfatih