Skip to content

Bug and solution: angularfire2 auth not working with angular universal #1270

Closed

Description

@hiepxanh

Thanks for @katowulf advice.

Think you found a bug?

Yes, I found a bug in angular auth when running on nodejs with angular universal universal starter repo

Version info

  • @angular/ 4.2.4
  • firebase: 4.5.0
  • angularfire2: 5.0.rc-2

Steps to set up and reproduce

  1. clone universal starter repo
  2. add firebase module to app module
  3. add auth in app.component.ts
    image
  4. run npm run build:dynamic && npm run serve:dynamic
  5. get error

I make an sample repository here to view my code

ERROR

Failing test unit, Plunkr, or JSFiddle demonstrating the problem
image

Expected behavior

In my opinion, angularfire2 already have XMLHttpRequest library, but maybe some problem when bootstrap. Maybe you can fix this bug and I don't have to add XMLHttpRequest manually

Actual behavior

get error with XMLHttpRequest.
Solution: I add this on top, error gone.

// server.ts file
(global as any).XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
// your code next...

Activity

  1. changed the title [-]angularfire2 auth not working with angular universal[/-] [+]Bug and solution: angularfire2 auth not working with angular universal[/+] on Oct 16, 2017
  2. patrickmichalina commented on Oct 17, 2017

    @patrickmichalina

    Firebase doesn't official support universal yet :(

    I have worked Auth and the RTDB into my starter with some dependency injection monkey patching if you want to try it out before official universal support is here:

    https://github.com/patrickmichalina/fusebox-angular-universal-starter

  3. hiepxanh commented on Oct 17, 2017

    @hiepxanh
    ContributorAuthor

    thank you for that

  4. davideast commented on Jan 9, 2018

    @davideast
    Collaborator

    Closing to keep issues consolidated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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