我正在学习Firebase使用身份验证NextJS,尝试理解使用多个源(文章/youtube),但我遇到了这个错误
ReferenceError: Cannot access 'auth' before initialization
老实说我仍在尝试寻找the source但仍然卡住了
这是我的firebase.js
import { firebase, initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
const firebaseConfig = {
apiKey: process.env.APIKEY,
authDomain: process.env.AUTH,
projectId: process.env.PID,
storageBucket: process.env.BUCKET,
messagingSenderId: process.env.MSID,
appId: process.env.AID,
measurementId: process.env.MID,
};
const app = !firebase.apps.length
? initializeApp(firebaseConfig)
: firebase.app();
const analytics = getAnalytics(app);
const auth = app.auth();
const db = app.firestore();
const googleProvider = new firebase.auth.GoogleAuthProvider();
export {
auth,
db,
signInWithGoogle,
... …Run Code Online (Sandbox Code Playgroud)