Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
Firebase onAuthStateChanged listener never fires on localhost despite being authorized

Fairly experienced with Firebase, encountering a strange and unintuitive bug. I've written a Firebase authentication wrapper using the React Context API, and track the currently logged in user with a listener. Here is my code:

useEffect(() => {
  console.log("Registering firebase auth listener");

  const unsubscribe = fa.onAuthStateChanged(
    fa.getAuth(),
    function (user) {
      console.log(user);
      setCurrentUser(user);
    },
    (error) => console.error(error),
    () => console.warn("Firebase listener unhooked")
  );

  return unsubscribe;
}, []);

Up until recently, this worked fine, but something has caused it to stop working only on localhost with no error message. The print at the top for checking that the hook runs gets logged, but nothing else.

Localhost is approved in the firebase dashboard

I don't understand what's going on here. Is there something obvious I've missed?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Solved my problem. I'd accidentally removed the initialization of firebase. To anyone reading this, if your onAuthStateChanged is mysteriously not firing, make sure you run initializeApp first.

If you're importing the intialization from another module, make sure you import the initialization code first.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!