Nuxt.jsとFirebase Authenticationで認証機能を作る

はじめに

firebase.js

import firebase from "firebase/app"
import "firebase/auth"
import "firebase/storage"
import "firebase/firestore"

if (!firebase.apps.length) {
  firebase.initializeApp({
    apiKey: process.env.FIREBASE_API_KEY,
    authDomain: process.env.FIREBASE_AUTH_DOMAIN,
    databaseURL: process.env.FIREBASE_DATABASE_URL,
    projectId: process.env.FIREBASE_PROJECT_ID,
    storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
    messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID,
    appId: process.env.FIREBASE_APP_ID,
    measurementId: process.env.FIREBASE_MEASUREMENT_ID,
  })
}
export const auth = firebase.auth()
export const storage = firebase.storage()
export const db = firebase.firestore()
export default firebase

CORS周り

HTTP 関数