Firebase 功能 HTTPS 403 禁止

2024-01-07

我使用 Node 和 Express 构建了 Firebase HTTP 事件函数。该函数正在工作,但是当我在客户端调用该函数时,我得到403 Forbidden。第一次调用该功能时,我被要求使用 Google 帐户登录。我使用与 Firebase 使用的帐户相同的帐户登录,但是当我调用该函数时,我得到:

403错误截图 https://i.stack.imgur.com/g22q6.png

我查看了Google云平台上的使用角色,调用该函数的权限设置为allUsers。我在 Firebase CLI 中注销并再次登录。

这里是index.js在函数文件夹中:

const functions = require('firebase-functions');
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const port = process.env.port || 5600
const nodemailer = require('nodemailer');

app.use(express.static('Public'));

app.use(bodyParser.urlencoded({ extended: true }));

const urlencodedParser = bodyParser.urlencoded({extended: true});

app.post("/api/user", urlencodedParser, (req, res) => {
  res.sendFile('../Public/bedankt.html', {root: __dirname})
  const persGegevens = req.body

  const string = JSON.stringify(persGegevens, (key, value) => {
    if (typeof value === "string"){
      return value.toUpperCase();
    } else {
      return value
    }
  }, 1);

  var transporter = nodemailer.createTransport({
    service: 'gmail',
    auth: {
      user: '[email protected] /cdn-cgi/l/email-protection',
      pass: 'Gietvloermakers2020!'
    }
  });

  var mailOptions = {
    from: '[email protected] /cdn-cgi/l/email-protection',
    to: '[email protected] /cdn-cgi/l/email-protection',
    subject: 'Nieuwe bestelling op Gietvloermakers',
    html: string
  };

  transporter.sendMail(mailOptions, function(error, info){
    if (error) {
      console.log(error);
    } else {
      console.log('Email sent: ' + info.response);
    }
  });
});

exports.app1 = functions.https.onRequest(app);

app.listen(port);

console.log(port);

这是 HTML:

<form id="controlleer-form" action="/api/user" method="post" enctype="application/x-www-form-urlencoded">
    <div class="controleer-div">
        <h2>Uw bestelling</h2>
        <p>Aantal m2</p>
        <input class="controle-input" type="text" name="aantalM2" id="aantalM2" readonly>
        <p>Kleur</p>
        <input class="controle-input" type="text" name="kleur" id="kleur" readonly>
        <p>Assistentie</p>
        <input class="controle-input" type="text" name="assistentie" id="assistentie" readonly>
        <p>Gereedschappen</p>
        <input class="controle-input" type="text" name="gereedschappen" id="gereedschappen" readonly>
        <p>Totale prijs</p>
        <input  class="controle-input" type="text" name="totale-prijs" id="totale-prijs" readonly>
        <a href="bestellen.html"><p id="andere-kleur">Bestelling aanpassen</p></a>
    </div>
    <div class="controleer-div">
        <h2>Uw gegevens</h2>
        <p>Voornaam</p>
        <input type="text" name="voornaam" placeholder="Voornaam">
        <p>Achternaam</p>
        <input type="text" name="Achternaam" placeholder="Achternaam">
        <p>Straatnaam en huisnummer</p>
        <input type="text" name="Achternaam" placeholder="Straatnaam en huisnummer">
        <p>Postcode</p>
        <input type="text" name="Achternaam" placeholder="Postcode">
        <p>Telefoonnummer</p>
        <input type="tel" name="telefoonnummer" placeholder="Telefoonnummer">
        <p>Emailadres</p>
        <input type="email" name="email" placeholder="Emailadres"><br>
        <input id="verzenden" type="submit"> 
    </div>
</form>

这是 firebase.json:

{
  "hosting": {
    "public": "Public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [{
      "source": "**",
      "function": "app1"
    }]
  }
}

我尝试过,但我已经用尽了迄今为止在网上找到的所有可能的解决方案。


我最近遇到了这个。事实证明,从 2020 年 1 月 15 日起,新功能默认需要身份验证。

See 这里的文档 https://cloud.google.com/functions/docs/securing/managing-access-iam#allowing_unauthenticated_function_invocation了解详情。

解决方案是手动添加Cloud Functions Invoker的许可allUsers用户位于 Google Cloud Console 的 Cloud Functions 页面中。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Firebase 功能 HTTPS 403 禁止 的相关文章

随机推荐

  • 为什么通用 ICollection 不在 .NET 4.5 中实现 IReadOnlyCollection?

    在 NET 4 5 C 5 中 IReadOnlyCollection
  • UISwipeGestureRecognizer 滑动长度

    知道是否有办法获取滑动手势或触摸的长度 以便我可以计算距离 不可能通过滑动手势获得距离 因为当手势结束时 SwipeGesture 会触发您可以准确访问该位置一次的方法 也许您想使用 UIPanGestureRecognizer 如果您可以
  • 如何从 Azure 数据工厂运行 PowerShell

    I have PowerShell该脚本将复杂的 CSV 文件分割为每 1000 条记录的较小的 CSV 文件 这是代码 i 0 Get Content C Users dell Desktop Powershell Input bigsi
  • SignTool 错误:访问被拒绝

    我正在尝试使用 pfx 文件签署外部 dllSignTool在cmd exe中使用以下代码 SignTool 签名 f MyCert pfx p MyPassword MyControl dll 但是 我不断收到以下错误消息 Done Ad
  • 如何过滤列表

    我正在编写一个简单的函数 从列表中取出任何奇数并返回仅包含偶数的列表 def purify numbers for i in numbers if i 2 0 numbers remove i return numbers print pu
  • 无法从其他应用程序读取 SharedPreferences

    EDITED 我有一个应用程序可以像这样写入 SharedPreferences Context otherAppsContext null try otherAppsContext createPackageContext AfroKey
  • 如何获取 jPlayer 中歌曲当前播放的时间? [关闭]

    很难说出这里问的是什么 这个问题是含糊的 模糊的 不完整的 过于宽泛的或修辞性的 无法以目前的形式得到合理的回答 如需帮助澄清此问题以便重新打开 访问帮助中心 help reopen questions 我使用 jPlayer 控件来播放音
  • 在notifyAppWidgetViewDataChanged之后没有调用RemoteViewService中的onDataSetChanged()

    在我的 AppWidgetProvider 类中 我有以下代码onUpdate method Update each of the widgets with the remote adapter for int appWidgetId ap
  • 完美转发、可变参数模板、initializer_list - 一起

    gcc 4 8 1 和 clang 3 3 c 11 功能完整 我需要在某些构造 make shared c 14 make unique 等元素的函数中转发参数 但我对类型推导 转发初始值设定项列表 数组有问题 我需要的工作示例foo f
  • 了解托管 bean/支持 bean [重复]

    这个问题在这里已经有答案了 我正在学习 Java EE 6 我正在尝试掌握它的整体形象 我正在阅读有关 JSF 以及如何添加组件的内容 我正在将组件中的值设置 读取到具有 ManagedBean 注释的 bean 我在正确理解它时遇到一些困
  • 单个变量的线程安全

    我了解线程安全的概念 我正在寻找在尝试保护单个变量时简化线程安全的建议 假设我有一个变量 double aPass 我想保护这个变量 所以我创建了一个互斥体 pthread mutex t aPass lock 现在我可以想到两种好方法 但
  • 导入打字稿时如何在路径中使用变量

    是否可以将变量 或常量 放入路径中 而不是将整个路径写为字符串文字 看起来 Angular 除了字符串文字之外不接受任何内容 import aClass require simpleClass import aComponent from
  • 将 pandas 数据框转换为 pandas 系列

    我需要一些有关数据类型问题的帮助 我正在尝试转换 pandas 数据框 如下所示 timestamp number 2018 01 01 1 2018 02 01 0 2018 03 01 5 2018 04 01 0 2018 05 01
  • 从 NSURLConnection 的响应头中读取数据

    如何从服务器响应中发送的标头中读取数据 我正在使用 NSURLConnection 发送请求 如果 URL 是 HTTP URL 则NSURLResponse您在连接的委托中收到的 connection didReceiveResponse
  • xampp mysql 和 phpmyadmin 不起作用

    昨天我使用 xampp 并使用 apache 和 mysql 服务 今天想启动mysql服务 没成功 我尝试在论坛上搜索解决方案 但找不到任何内容 所以我问你 在 mysql 停止工作后 我在日志文件中找到此消息 2015 10 29 12
  • ASP.NET MVC 将数据从视图传递到控制器

    我有一个带有网格的视图 其中包含添加到工作站的项目 用户可以从下拉列表中选择一个项目 然后单击一个操作链接 该链接调用控制器将该项目添加到工作站 我可以通过读取控制器的 Post 操作中的 FormCollection 对象来使其工作 p
  • 如何在 AWS 负载均衡器响应中禁用 Apache HTTP 标头信息?

    我在 Apache 服务器上使用 AWS Elastic Beanstalk 部署了一个 node js 环境 我对环境运行了 PCI 扫描 但出现了 2 次失败 Apache ServerTokens 信息披露 Web服务器HTTP头信息
  • 从逗号分隔字段中选择

    说我有一个subscribers表 每个用户都有一行 如下所示 id name subscribers 1 user1 user2 user3 user4 2 user2 user4 user5 user3 3 user3 user1 us
  • Apache Spark:核心数量与执行器数量

    我试图了解在 YARN 上运行 Spark 作业时核心数量和执行器数量的关系 测试环境如下 数据节点数量 3 Data node machine spec CPU Core i7 4790 核心数 4 线程数 8 内存 32GB 8GB x
  • Firebase 功能 HTTPS 403 禁止

    我使用 Node 和 Express 构建了 Firebase HTTP 事件函数 该函数正在工作 但是当我在客户端调用该函数时 我得到403 Forbidden 第一次调用该功能时 我被要求使用 Google 帐户登录 我使用与 Fire