部署 Firebase Web 应用程序时出现 404 错误

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

您好,当我部署 Firebase Web 应用程序时,在访问端点时收到 404 未找到错误。

这是在 src/routes/functions 文件夹中找到的 index.js 文件的一部分。

const port = process.env.PORT || 80;
server.listen(port,'127.0.0.1');
console.debug('Server listening on port ' + port);

// Your web app's Firebase configuration
var firebaseConfig = {
  apiKey: "*",
  authDomain: "*",
  databaseURL: "*",
  projectId: "*",
  storageBucket: "*",
  messagingSenderId: "93371481008",
  appId: "*",
  measurementId: "G-NR8N5HP6RZ"
};
// Initialize Firebase
if (!firebase.apps.length) {
  firebase.initializeApp(firebaseConfig);
}else {
  firebase.app(); // if already initialized, use that one
}
router.get('/test', function(req,res){
  console.log("router map test");
  res.send("test page");
});

当我通过键入以下内容来部署 Firebase Web 应用程序时:

sudo firebase deploy

当我尝试点击 index.js 中的测试端点时 -

curl -X GET https://PROJECT_ID/test
我收到 404 错误。

这是我的 firebase.json 文件:

  "hosting": {
    "public": "src/main/www",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  },```
  "functions": [
    {
      "source": "src/routes/functions",
      "codebase": "map-print",
      "ignore": [
        "node_modules",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ]
    }
  ],
  "rewrites": [
    {
      "source": "/test",
      "function": "test"
    }
  ]
}



node.js firebase deployment http-status-code-404 endpoint
1个回答
0
投票

我想你缺少导出函数本身。

尝试将其添加到文件末尾:

exports.myFuncionName = functions.https.onRequest( router )
© www.soinside.com 2019 - 2024. All rights reserved.