最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to use react-native-firebase auth emulation? - Stack Overflow

programmeradmin0浏览0评论

im using react-native-firebase v21.6.1 and im trying to start the auth service emulation. Ive gotten the firestore and functions emulation working.

firebase.json

"emulators": {
  "functions": {
    "port": 5001
  },
  "firestore": {
    "port": 8080
  },
  "auth": {
    "port": 9099
  },
  "ui": {
    "enabled": true
  },
  "singleProjectMode": true
}

app.js:

import functions from '@react-native-firebase/functions';
import firestore from '@react-native-firebase/firestore';
import auth from '@react-native-firebase/auth';

...
if (__DEV__) {
  firestore().useEmulator('localhost', 8080);
  functions().useEmulator('localhost', 5001);
  auth().useEmulator('http://localhost:9099');
}

It seems to have connected successfully:

Using auth().createUserWithEmailAndPassword would throw this error:

Error: [auth/network-request-failed] A network error has occurred, please try again.]

I execute npx expo run:ios to start a development build on the ios simulator.

im using react-native-firebase v21.6.1 and im trying to start the auth service emulation. Ive gotten the firestore and functions emulation working.

firebase.json

"emulators": {
  "functions": {
    "port": 5001
  },
  "firestore": {
    "port": 8080
  },
  "auth": {
    "port": 9099
  },
  "ui": {
    "enabled": true
  },
  "singleProjectMode": true
}

app.js:

import functions from '@react-native-firebase/functions';
import firestore from '@react-native-firebase/firestore';
import auth from '@react-native-firebase/auth';

...
if (__DEV__) {
  firestore().useEmulator('localhost', 8080);
  functions().useEmulator('localhost', 5001);
  auth().useEmulator('http://localhost:9099');
}

It seems to have connected successfully:

Using auth().createUserWithEmailAndPassword would throw this error:

Error: [auth/network-request-failed] A network error has occurred, please try again.]

I execute npx expo run:ios to start a development build on the ios simulator.

Share Improve this question edited Feb 1 at 15:13 Frank van Puffelen 600k85 gold badges889 silver badges859 bronze badges Recognized by Google Cloud Collective asked Feb 1 at 10:38 benwlbenwl 49211 silver badges29 bronze badges 1
  • 1 In your app.js try changing localhost to 127.0.0.1. There are cases where localhost can resolve to ::1(on IPV6) instead of 127.0.0.1 – Marco Commented Feb 4 at 15:33
Add a comment  | 

1 Answer 1

Reset to default 0

Marco's answer is right,

I was facing the same issue as you and if you change

if (__DEV__) {
    firestore().useEmulator('localhost', 8080);
    storage().useEmulator('localhost', 9199);
-   auth().useEmulator("http://localhost:9099"); // from this
+   auth().useEmulator("http://127.0.0.1:9099"); // to this
}

Then i suggest to rebuild the app and log out of your app.

You will be able to see something like this in the console

发布评论

评论列表(0)

  1. 暂无评论