Why this error is showing " Uncaught FirebaseError: Firebase: Error (auth/invalid-api-key)"?

Why this error is showing " Uncaught FirebaseError: Firebase: Error (auth/invalid-api-key)"?

我正在尝试在我的项目中使用 firebase 身份验证。创建环境变量后,我收到此错误“Uncaught FirebaseError: Firebase: Error (auth/invalid-api-key).”

https://i.postimg.cc/gJzdG8nS/01.png

 import { initializeApp } from "firebase/app";
 import {getAuth} from 'firebase/auth';
 // TODO: Add SDKs for Firebase products that you want to use
 // https://firebase.google.com/docs/web/setup#available-libraries

 // Your web app's Firebase configuration
 const firebaseConfig = {
    apiKey:process.env.REACT_APP_apiKey,
    authDomain:process.env.REACT_APP_authDomain,
    projectId:process.env.REACT_APP_projectId,
    storageBucket:process.env.REACT_APP_storageBucket,
    messagingSenderId:process.env.REACT_APP_messagingSenderId,
    appId:process.env.REACT_APP_appId
 };

 // Initialize Firebase
 const app = initializeApp(firebaseConfig);

 const auth = getAuth(app);

 export default auth;
  1. 您需要将您的 .env.local 文件放在您的根目录中。
  2. 确保在您的 .env.local 中没有 (,) 或 ("") 或 ('') 或 (;) 存在。