【问题标题】:Firebase Cloud functions are not called不调用 Firebase Cloud 函数
【发布时间】:2020-02-09 10:43:37
【问题描述】:

当我访问“/s/:id”时,我的网站会调用函数“s”。
但是,它实际上从未被调用过。
正如 firebase 项目概述所证实的那样,没有证据表明函数已被调用。
我不知道为什么,因为控制台没有错误。

#functions/firebase.json
{
  "functions": {
    "source": "functions"
  },
  "hosting": {
    "public": "dist",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "rewrites": [
      {
        "source": "/s/*",
        "function": "s"
      },
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

访问“s /:id”时,不调用函数,而是应用“index.html”。
我知道首选“index.html”,因为它在“public”中,但我认为这不会是不调用顶部函数的原因。

#functions/index.js
const functions = require("firebase-functions");
const express = require("express");
const app = express();
const admin = require("firebase-admin");

admin.initializeApp(functions.config().firebase);

const db = admin.firestore();

const genHtml = (image_url, id) => `
<!DOCTYPE html>
<html>
  <head>
    //Meta tag to overwrite
  </head>
  <body>
  <script>
      location.href = '/share/${id}';
  </script>
  </body>
</html>
`;

app.get("s/:id", (req, res) => {

//processing

});
exports.s = functions.https.onRequest(app);

可能是什么原因?

【问题讨论】:

    标签: javascript firebase vue.js google-cloud-functions firebase-hosting


    【解决方案1】:

    通过匹配函数和数据库区域正确响应。我不知道这是否是原因,但它工作得如此接近。

    【讨论】:

      猜你喜欢
      • 2019-03-08
      • 2019-12-13
      • 2019-04-21
      • 2019-03-22
      • 2021-08-09
      • 2019-06-04
      • 1970-01-01
      • 1970-01-01
      • 2019-02-22
      相关资源
      最近更新 更多