【发布时间】:2021-10-01 07:32:44
【问题描述】:
我的函数模拟器正在调用生产版 Firestore,而不是 Firestore 模拟器。我不确定这是怎么发生的,因为我听说这是不可能的。
我已经设置了我的模拟器并加载了 Firestore 模拟器:
Emulator │ Host:Port │ View in Emulator UI │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Authentication │ 127.0.0.1:9099 │ http://127.0.0.1:4000/auth │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Functions │ 127.0.0.1:5001 │ http://127.0.0.1:4000/functions │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Firestore │ 127.0.0.1:8080 │ http://127.0.0.1:4000/firestore │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Hosting │ 127.0.0.1:5000 │ n/a │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Storage │ 127.0.0.1:9199 │ http://127.0.0.1:4000/storage │
这是我在函数中配置应用程序和 Firestore 的方式:
import { initializeApp } from 'firebase/app';
import {
getFirestore,
} from 'firebase/firestore';
let firebaseConfig = {
databaseURL: 'http://localhost:8080?ns=nft-public',
projectId: 'nft-public',
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
还有我在 firebase.json 中的模拟器选项
"emulators": {
"auth": {
"host": "localhost",
"port": "9099"
},
"firestore": {
"host": "localhost",
"port": "8080"
},
"functions": {
"host": "localhost",
"port": "5001"
},
"hosting": {
"port": 5000
},
"storage": {
"port": 9199
},
"ui": {
"enabled": true
}
}
【问题讨论】:
标签: firebase google-cloud-firestore