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;
CodePudding user response:
- You need to put your .env.local file in your root.
- Make Sure inside your .env.local no (,) or ("") or ('') or (;) exist.