【发布时间】:2020-05-13 18:28:21
【问题描述】:
我是firebase的新手,我已经部署了一个功能,它正在使用get方法,
https://us-central******.cloudfunctions.net/addMessage
当我尝试运行这个 api 时,我遇到了错误
Error: Forbidden
Your client does not have permission to get URL /addMessage from this server.
谁能帮我解决这个问题?
exports.addMessage = functions.https.onRequest(async (req, res) => {
// Grab the text parameter.
const original = req.query.text;
// Push the new message into the Realtime Database using the Firebase Admin SDK.
const snapshot = await admin.database().ref('/messages').push({ original: original });
// Redirect with 303 SEE OTHER to the URL of the pushed object in the Firebase console.
res.redirect(303, snapshot.ref.toString());
});
【问题讨论】:
-
我的第一个猜测是云功能上没有启用公共访问。如果是这种情况,请查看cloud.google.com/functions/docs/securing/…
标签: node.js firebase firebase-realtime-database google-cloud-functions