【发布时间】:2021-07-09 02:29:34
【问题描述】:
我在 firebase 云函数中创建了一些函数,但它们都是有效的。但是我有一个无法正常工作的新功能。我不知道为什么,但我认为它与其他人的模式相同。
这是我的代码:
const functions = require('firebase-functions');
const appVideo = express();
const cors = require('cors')({ origin: true });
appVideo.use(cors);
appVideo.get('/update-video', async(req, res) => {
console.log('updateStatusVideo idCourse', req.query.idCourse, ' idMateri: ', req.query.idMateri, ' idVideo:', req.query.idVideo);
res.status(200).send('Oke')
})
exports.video = functions.https.onRequest(appVideo)
我经常将部分部署称为
firebase deploy --only functions:video。但是当我通过浏览器执行 https 函数时,它通常会返回
请求失败,状态码 404
其他奇怪的事情是当我检查浏览器并切换到控制台时,我发现
加载资源失败:服务器响应状态为500()
这是firebase中函数的url:
https://us-central1-my-apps.cloudfunctions.net/video [已修改为机密]
请帮忙
【问题讨论】:
-
您是否尝试访问
https://us-central1-PROJECT_ID.cloudfunctions.net/video/update-video? -
请编辑问题以明确您尝试运行此功能的具体方式。问题应该包含足够的细节,任何人都可以重现你观察到的行为。在不知道 URL 的情况下,我们甚至不知道您是否正确指定了它。
-
@samthecodingman 是的
-
@DougStevenson 这是我在 firebase 中注册的函数:
https://us-central1-my-apps.cloudfunctions.net/video -
@samthecodingman 但我的 Firebase 中的网址是
https://us-central1-my-apps.cloudfunctions.net/video
标签: node.js firebase google-cloud-functions