Skip to content

Extracting Firebase config into environment variables #2

Description

@CanyonTurtle

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions