kan
kan

Reputation: 45

Firebase Cloud functions are not called

My site will call function "s" when I access " / s /: id".
However, it is never actually called.
As confirmed by firebase Project Overview, there is no evidence that function was called.
I don't know why because there is no error in the console.

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

When "s /: id" is accessed, function is not called, but "index.html" is applied.
I know that "index.html" is preferred because it is in "public", but I don't think it will be the reason why the function at the top is not called.

#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);

What can be the cause?

Upvotes: 0

Views: 620

Answers (1)

kan
kan

Reputation: 45

Responded correctly by matching the function and database regions. I don't know if this is the cause, but it worked so close it.

Upvotes: 1

Related Questions