Firebase HTTPS云函数在生产中返回404



我已经向Firebase推送了一个非常基本的HTTP云函数,当我试图在浏览器或Postman中访问时,我得到了一个404。该函数通过firebase serve和我使用firebase-functions-testSDK编写的各种测试在本地工作。

// import function libraries and initialize admin app
var functions = require('firebase-functions');
var admin = require('firebase-admin')
admin.initializeApp(functions.config().firebase)
// push data to a specific database
var pushData = (path) => (payload) => {
return new Promise((resolve, reject) => {
admin.database().ref(path).push(payload).then(snapshot => {
resolve(snapshot)
}).catch((error) => {
reject(error)
})
})
}
// github webhook endpoint
exports.postGitHubEvent = functions.https.onRequest((request, response) => {
// handle invalid request method
if (request.method !== 'POST') {
return response.send(405, 'Only POST Requests Are Accepted')
}
// push request body to database
var event = request.body
var writeData = pushData('github')(event)
// return write promise
return writeData.then(
result => response.send(200, `Successfully Pushed Github Event: ${result}`),
error => response.send(500, `Error in Pushing GitHub Event: ${error}`)
)
})

这个问题已经得到了回答。我的firebase项目ID中有两个hiphens,在项目创建时进行了自定义(编辑(。在项目名称/项目ID中保留一个hiphen,现在它可以正常工作。。。

相关内容

  • 没有找到相关文章

最新更新