Firebase throws “auth/network-request-failed” on s

2020-07-06 05:29发布

问题:

I'm writing some tests for my app (is build with create-react-app) using firebase and I'm trying to anonymously login into my test database. But authentication fails. However all other firebase operations (CRUD) work just fine.

I can also login anonymously from my application that runs in a browser.

The code is very simple:

import firebase from 'firebase';
firebase
    .auth()
    .signInAnonymously()
    .catch((err) => {
        console.log(err);
    });

Gives me back this:

O {
  code: 'auth/network-request-failed',
  message: 'A network error (such as timeout, interrupted connection or unreachable host) has occurred.'
}

But I actually see users that appear in the Firebase console:

Anonymous access is enabled:

And here are my access rules. But it never comes to the point of dealing with rules since I can't login.

{
  "rules": {
    "users": {
      "$user_id": {
        ".read": "$user_id === auth.uid",
        ".write": "$user_id === auth.uid"
      }
    }
  }
}

So what's going on? Are there any special things I need to do to make it work in command line? Or should I switch anything in the firebase console?

Maybe any hint on how can I debug it deeper?

Thanks!