firecmsco / firecms

Awesome Firebase/Firestore-based CMS. The missing admin panel for your Firebase project!
https://firecms.co
Other
1.14k stars 185 forks source link

How can I use firebase emulators with FireCMS? #530

Closed mvarchdev closed 1 year ago

mvarchdev commented 1 year ago

I had a bad time lately analysing of how to implement emulators for FireCMS for quick developement. Is there some quick approach?

I have prepared something like this but it is not working:

    const onFirebaseInit = (config: object, app: FirebaseApp) => {
        if (process.env.NODE_ENV !== "production") {
            firebase.firestore().useEmulator("localhost", 8080);
            firebase.auth().useEmulator("http://localhost:9099/");
            firebase.storage().useEmulator("localhost", 9199);

        }
    };

Thanks a lot advance! It would be great for our company.

mvarchdev commented 1 year ago

Used this solution:

    const onFirebaseInit = async () => {
        if (developement) {
            const db = getFirestore();
            const storage = getStorage();
            const auth = getAuth();

            connectFirestoreEmulator(db, 'localhost', 8080);
            connectStorageEmulator(storage, 'localhost', 9199);
            connectAuthEmulator(auth, 'http://localhost:9099');
        }
    };