【发布时间】:2021-11-10 02:31:38
【问题描述】:
我正在运行 firebase 模拟器。
如果允许用户(取决于数据库中的值),我的应用程序可以调用可以创建自定义用户声明的 firebase 云函数
我正在尝试调用该函数:
import * as firebase from '@firebase/testing';
import * as fs from 'fs';
const app = firebase.initializeTestApp({
databaseName: 'mydb',
auth: {
uid: 'useruid'
},
});
describe('Firebase Functions', () => {
beforeEach(async () => {
await firebase.loadDatabaseRules({
databaseName: 'mydb',
rules: fs.readFileSync('database.rules.json', 'utf8'),
});
});
afterAll(async () => {
await Promise.all(firebase.apps().map((app) => app.delete()));
});
const cloudfunction = app.functions().httpsCallable('cloudfunction')
it('throws error if user is not authenticated', async () => {
await firebase.assertFail(cloudfunction())
})
});
这是抛出一个错误:
错误:错误:预检响应包含无效的 HTTP 状态代码 404
【问题讨论】:
标签: javascript firebase-authentication google-cloud-functions firebase-tools