Skip to content

Auth useEmulator() does not redirect authState requests to emulator  #2637

Closed
@jornetsimon

Description

@jornetsimon

Version info

Angular:
10.2.0

Firebase:
8.0.1

AngularFire:
6.0.4

How to reproduce these conditions

Failing test unit, Stackblitz demonstrating the problem

Simple context recreation in a repo since StackBlitz won't help with emulators.
https://github.com/jornetsimon/af-auth-debug

Steps to set up and reproduce

  • Set up the Firebase Authentication emulator.
  • Set up an authentication method (email/password for example) and implement it on a page
  • Call this.afAuth.useEmulator('http://localhost:9099/') (or whatever the port is set to).
  • Subscribe to authState from another page
  • Sign up : the user is authenticated correctly
  • Reload the app
  • The call to authState returns a 400 INVALID_ID_TOKEN error, and the request URL points to Firebase servers (googleapis.com)

Debug output

Without useEmulator :
Screen Shot 2020-11-07 at 19 46 46

With useEmulator :
Screen Shot 2020-11-07 at 19 45 08

Expected behavior

When using useEmulator(), the call to retrieve the authState should target the emulator (localhost:9099).
AngularFireAuth.user and AngularFireAuth.user should return the previously authenticated user.

Actual behavior

During the sign up process (createUserWithEmailAndPassword() / signInWithEmailLink), the calls point to the emulator.
But that is not the case with authState.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions