Md Ahanaf Islam
Md Ahanaf Islam

Reputation: 3

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

I'm trying to use firebase authentication in my project. After creating the environment variable I'm getting this error "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;

Upvotes: 0

Views: 548

Answers (1)

Arick Hasan
Arick Hasan

Reputation: 36

  1. You need to put your .env.local file in your root.
  2. Make Sure inside your .env.local no (,) or ("") or ('') or (;) exist.

Upvotes: 2

Related Questions