Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
11
Help us understand the problem. What is going on with this article?
@IZUMIRU

[Nuxt.js] Firebaseの設定で環境変数dotenvを扱う

More than 1 year has passed since last update.
$ npm i --save @nuxtjs/dotenv
$ yarn add @nuxtjs/dotenv
nuxt.config.js
  plugins: [
    '~/plugins/firebase.js',
  ],
  modules: [
    '@nuxtjs/dotenv',
  ],
plugins/firebase.js
import firebase from "firebase/app";
import "firebase/auth";

if (!firebase.apps.length) {
  firebase.initializeApp({
    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,
    appId: process.env.APP_ID
  })
}

export default firebase;

.envファイル

API_KEY='AIXXXXXXXXXXXXXXXXXXXXXXXX'
AUTH_DOMAIN='hogefuga.firebaseapp.com'
DATABASE_URL='https://hogefuga.firebaseio.com'
PROJECT_ID='hogefugao'
STORAGE_BUCKET='hogefuga.appspot.com'
MESSAGING_SENDER_ID='123456789'
APP_ID='1:123456789:web:abcde1234'

参考

11
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
IZUMIRU
まいにちがんばる。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
11
Help us understand the problem. What is going on with this article?