admin管理员组文章数量:1391030
I am a newbie, and I am stuck. I don`t know what to do. My browser is showing that fire store is not able to connect to the backend. This is my code :
import firebase from 'firebase/pat/app';
import 'firebase/pat/auth';
import 'firebase/pat/firestore';
import 'firebase/pat/storage';
import {initializeApp} from 'firebase/app'
const firebaseConfig = initializeApp({
apiKey: "AIzaSyA9BnlX96fMf7XiUVCFRsoQzG8DGERJkeY",
authDomain: "disneyplus-clone-a33d5.firebaseapp",
projectId: "disneyplus-clone-a33d5",
storageBucket: "disneyplus-clone-a33d5.appspot",
messagingSenderId: "37918794208",
appId: "1:37918794208:web:dbe9842dfe1dda522a4b85",
measurementId: "G-DRVLJKWRWG",
});
const firebaseApp = firebase.initializeApp(firebaseConfig);
const db = firebaseApp.firestore();
const auth = firebase.auth();
const provider = new firebase.auth.GoogleAuthProvider();
const storage = firebase.storage();
export { auth, provider, storage };
export default db;
I am a newbie, and I am stuck. I don`t know what to do. My browser is showing that fire store is not able to connect to the backend. This is my code :
import firebase from 'firebase/pat/app';
import 'firebase/pat/auth';
import 'firebase/pat/firestore';
import 'firebase/pat/storage';
import {initializeApp} from 'firebase/app'
const firebaseConfig = initializeApp({
apiKey: "AIzaSyA9BnlX96fMf7XiUVCFRsoQzG8DGERJkeY",
authDomain: "disneyplus-clone-a33d5.firebaseapp.",
projectId: "disneyplus-clone-a33d5",
storageBucket: "disneyplus-clone-a33d5.appspot.",
messagingSenderId: "37918794208",
appId: "1:37918794208:web:dbe9842dfe1dda522a4b85",
measurementId: "G-DRVLJKWRWG",
});
const firebaseApp = firebase.initializeApp(firebaseConfig);
const db = firebaseApp.firestore();
const auth = firebase.auth();
const provider = new firebase.auth.GoogleAuthProvider();
const storage = firebase.storage();
export { auth, provider, storage };
export default db;
And if i delete the initializeApp
from const firebaseConfig
it gives my the following error:
@firebase/firestore: Firestore (9.2.0): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=permission-denied]: Permission denied on resource project disneyplus-clone-a33d5. This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
Hope you can help me. Thank you !
Share Improve this question asked Nov 1, 2021 at 19:25 iulianiulian 411 silver badge2 bronze badges5 Answers
Reset to default 2I got this error after messing with my firebase project (in the firebase console). In the end I discovered that my firebase_options.dart
file was outdated, so I had to run
flutterfire configure
in order to regenerate those option files and then my problem was solved...
can you try this workaroun. let me know if this helps
const firebaseApp = firebase.initializeApp(firebaseConfig);
const db = firebaseApp.firestore();
//workaround
db.settings({ experimentalForceLongPolling: true });
This is what I did
- Create a file called
firebase.tsx
and add this
// firebase.tsx
import { initializeApp, getApp } from "firebase/app";
const firebaseConfig = {
// firebaseconfig keys
};
const app = initializeApp(firebaseConfig);
export { app };
- Then where ever you want to use any firebase features you can just import the
app
like this
import {app} from './your/path/to/firebase.tsx'
const db = getFirestore(app);
and then use it as a normal firebase.
P.S This works for firebase v9
I faced this issue when I changed the firebase project in firebase console for my REACT NATIVE ANDROID APP. to fix this issue there is a needs to clean the builds and related files. Steps:-
- cd android
- ./gradlew clean or gradlew clean
- ./gradlew cleanBuildCache
- npm run android
import firebase from 'firebase/pat/app';
import 'firebase/pat/auth';
import 'firebase/pat/firestore';
import 'firebase/pat/storage';
import {initializeApp} from 'firebase/app'
const firebaseConfig = initializeApp({
apiKey: "AIzaSyA9BnlX96fMf7XiUVCFRsoQzG8DGERJkeY",
authDomain: "disneyplus-clone-a33d5.firebaseapp.",
projectId: "disneyplus-clone-a33d5",
storageBucket: "disneyplus-clone-a33d5.appspot.",
messagingSenderId: "37918794208",
appId: "1:37918794208:web:dbe9842dfe1dda522a4b85",
measurementId: "G-DRVLJKWRWG",
});
const firebaseApp = firebase.initializeApp(firebaseConfig);
const db = firebaseApp.firestore();
const auth = firebase.auth();
const provider = new firebase.auth.GoogleAuthProvider();
const storage = firebase.storage();
export { auth, provider, storage };
export default db;
Add this in Flutter
NOTE - Use this "Firebase.initializeApp" only Once in the entire Project.
// Wait for Default Firebase app to initialize
if (Firebase.apps.isEmpty) {
await Firebase.initializeApp(
name: 'YourAPP',
options: DefaultFirebaseOptions.currentPlatform,
).whenComplete(() {
print("pletedAppInitialize");
// setState(() {});
});
}
本文标签:
版权声明:本文标题:javascript - Firebase: Firebase App named '[DEFAULT]' already exists with different options or config (appduplic 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744595493a2614750.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论