Skip to content

Firebase client sometimes tries to production server while using connectAuthEmulator #8519

Closed
@bunyaminmrcn

Description

@bunyaminmrcn

Operating System

Kali Linux

Environment (if applicable)

Chrome 129, Firefox 130

Firebase SDK Version

10.13.2

Firebase SDK Product(s)

Auth

Project Tooling

next project with next-auth@4.24.7

Detailed Problem Description

I set it up local emulator for firebase auth & firestore & storage & functions. But issue happen while authorizing

Steps and code to reproduce issue

I run initEmulator function in useEffect hook after login. It asks to credentials to production server
(https://identitytoolkit.googleapis.com/v1/accounts:lookup)

import { initializeApp, getApp } from 'firebase/app';
import { connectAuthEmulator, getAuth } from 'firebase/auth';

const firebaseConfig = {
  apiKey: "test",
  authDomain: 'http://127.0.0.1:9099',
  databaseURL: "http://127.0.0.1:8080",
  projectId: "test",
};

const firebaseApp = initializeApp(firebaseConfig);

let initialized = false;
const initEmulator = () => {
  if (!initialized) {
    try {
      
      connectAuthEmulator(firebaseAuth, 'http://127.0.0.1:9099')
      console.log("Connected to Emulator")
      initialized = true;
    } catch(err) {
      console.log("Error occured")
    }
    
  }
}

const firebaseAuth = getAuth(firebaseApp)
export { firebaseApp, firebaseAuth, initEmulator }


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions