Firebase HTTP Cloud Function HTTP错误代码403

问题描述 投票:1回答:1

自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);
    });
});

我正在使用我刚刚看到的库“ request”,该库在2个月前已被弃用。可能是问题所在? https://www.npmjs.com/package/request

firebase google-cloud-functions http-status-code-403
1个回答
2
投票

[Cloud Functions最近将其新功能的默认IAM策略更改为仅限于项目所有者(以前是allUsers,允许公众访问)。

[为准备此更改,[email protected]添加了有关功能创建的IAM策略更新,该更新添加了allUsers权限。如果使用的是旧版CLI,则可能会在受限模式下部署新功能。

但是,重要的是,此更改仅应适用于新功能的创建-如果一个功能已经存在并且仅被更新,则不应发生IAM更改。如果在更新功能时遇到其他问题,请file a detailed issue包括带有firebase-tools的调试日志。

© www.soinside.com 2019 - 2024. All rights reserved.