question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

firebase emulators:start the `__/firebase/init.js` points at the web and not local eumulators

See original GitHub issue

I have my Firebase stuff setup locally and the emulators work fine (I can get into the UI and everything) but when I access my webapp locally at http://localhost:5000/ and look at the contents of init.js all the variables point at the cloud datastore and stuff.

My unit tests will talk to the emulator by doing this:

var authenticatedApp = firebaseTesting.initializeTestApp({
    databaseName: "blahblah-d46ae",
    auth: { uid: "alice", email: "alice@example.com" }
})

beforeAll((done) => {
    //initFirebase();
    done()
})

afterAll((done) => {
    //firebase.database().goOffline();
    Promise.all(firebaseTesting.apps().map(app => {
        app.delete()
    })).finally(done)
})

How do I start the emulator so that init.js will point to everything locally (functions, database, etc…)?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
yuchenshicommented, Jul 19, 2021

@PaulRudin You can now opt-in to an emulated init.js by adding ?useEmulator=true flag, like so:

<script defer src="/__/firebase/init.js?useEmulator=true"></script>

For new projects initialized from the Firebase CLI, this flag will be automatically set for you in the generated public/index.html.

This flag has no effect in production Firebase Hosting and it only configures enabled and running emulators. If you want the Auth Emulator, please run firebase init emulators first and check it from the list.

0reactions
PaulRudincommented, Jul 18, 2021

This is still an issue, and now there’s an auth emulator, so presumably it should be possible to coax the emulator to do the right thing when running locally.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Run functions locally | Cloud Functions for Firebase - Google
The emulators:start command will start emulators for Cloud Functions, Cloud Firestore, Realtime Database, and Firebase Hosting based on the products you ...
Read more >
Firestore/Firebase Emulator Not Running - Stack Overflow
Run firebase emulators:start . Check if displayed error request to install OpenJDK. If your functions interacts with Firebase APIs or Google ...
Read more >
The Full Guide on how to use the Firebase Emulator for the Web
That's because the reads or writes to your local database don't count against your quota, ... firebase init emulators ... firebase emulators:start.
Read more >
Local Testing With the Firebase Emulator Suite - Medium
json file. firebase init emulators. Choose functions, firestore, database to begin. We will go through the optional auth emulator, which has ...
Read more >
How to configure Firebase emulators with Next.js?
The backend folder contains the functions, and it's where you initialize the Firebase project (i.e., run the firebase init com). The web folder ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found