【发布时间】:2020-03-30 07:04:10
【问题描述】:
自 2020 年 3 月 28 日起,我的所有 HTTP 云功能都出现错误。在我上次更新之前,它们工作正常。我只改变了一些东西,在最后一次部署后我得到了这个错误:
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>403 Forbidden</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Forbidden</h1>
<h2>Your client does not have permission to get URL <code>/api/v0/.../</code> from this server.
</h2>
<h2></h2>
</body>
</html>
我所做的所有更改都不仅仅指 BI 中的 HTTP 函数实现。 还有其他人有同样的错误吗?从 Firebase 状态控制台看,firebase 似乎没有遇到任何错误https://status.firebase.google.com/
编辑:添加了关于我如何初始化 HTTP 云函数的摘录。
'use strict';
// node import
const cors = require('cors')({ origin: true });
const functions = require('firebase-functions');
const admin = require('firebase-admin');
// Setting timeout and memory for the deploy
const runtimeOpts = {
timeoutSeconds: 540,
memory: '2GB'
}
admin.initializeApp();
exports.exportMultipleDataToCSV = functions
.runWith(runtimeOpts)
.https.onRequest((request, response) => {
cors(request, response, () => {
if (request.method === 'PUT') response.status(403).send('Forbidden!');
if (request.method === 'DELETE') response.status(403).send('Forbidden!');
if (request.method === 'POST') response.status(403).send('Forbidden!');
// BI
let data = MY-BI;
response.status(200).set('Access-Control-Allow-Origin', '*').send(data);
});
});
我正在使用我刚刚看到的已在 2 个月前弃用的库“请求”。这可能是问题所在? https://www.npmjs.com/package/request
【问题讨论】:
-
如果这不符合您的预期,您应该直接联系 Firebase 支持。 support.google.com/firebase/contact/support
-
我做到了,对他们来说,这与我有关。但是直到 28 个他们工作正常......我们谈论的是 36 个函数,我只对一个函数做了一些更改,然后我重新部署了所有函数。
-
请问可以看一下实例化云函数的代码吗?
-
我放了一段关于如何初始化 HTTP 云函数的代码摘录。这是针对没有身份验证的 API。
-
经历了同样的事情,几周前一切正常。计费帐户已配置,serviceAccount 已正确安装。如果我发现任何东西会更新。
标签: firebase google-cloud-functions http-status-code-403