question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Read Firebase API keys from .env

See original GitHub issue

I’m sure this has been discussed before but I can’t seem to find the thread. Anyway, I’m trying to set the config from process.env inside nuxt.config.js but the value seems to be empty.

Is there another way to do this, say via plugin?

firebase: {
  config: {
    apiKey: process.env.apiKey,
    authDomain: process.env.authDomain,
    databaseURL: process.env.databaseURL,
    projectId: process.env.projectId,
    storageBucket: process.env.storageBucket,
    messagingSenderId: process.env.messagingSenderId,
    appId: process.env.appId,
    measurementId: process.env.measurementId
  },
  services: {
    auth: true  
  }  
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
kwatogcommented, Mar 7, 2020

apologies, noob mistake. I forgot to add require('dotenv').config() at the top of the nuxt.config.js

0reactions
CodeMat17commented, Oct 6, 2020

Thanks Mike for responding and swiftly too, I’ll look at it now.

On Tue, 6 Oct 2020, 4:11 pm mikoy, notifications@github.com wrote:

here’s the link to my nuxt.config.js https://github.com/kwatog/manbok/blob/master/nuxt.config.js

take note that the env file should be named “.env” as dotenv only reads that filename. it won’t accept any other filename.

and then you need to make sure to load env before the export block

require(‘dotenv’).config() export default {

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nuxt-community/firebase-module/issues/113#issuecomment-704338281, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGF5DHVELFUSXVPO7G53DQTSJMXRJANCNFSM4LDPZBJA .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Learn about using and managing API keys for Firebase - Google
An API key is a unique string that's used to route requests to your Firebase project when interacting with Firebase and Google services....
Read more >
Environment variables not working for hiding firebase API key
I want to hide my firebase API key with ...
Read more >
env firebase API key returns undifined - Netlify Support Forums
Some reason I can`t access the env variables in firebase-config. meh .env (in root folder / ) REACT_APP_API_KEY = asdheyhohellothankyou1 ...
Read more >
Firebase Functions: React users need to stop storing sensitive ...
Many of you are reading this because you are an awesome Front-End Developer ... Well, if you have sensitive API keys and you...
Read more >
Using secrets | Cloud Functions Documentation
You can use Secret Manager to securely store API keys, passwords, and other sensitive information. This guide shows you how to configure Cloud...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found