【问题标题】:Firebase Hosting with Function Not Working Locally功能无法在本地工作的 Firebase 托管
【发布时间】:2018-06-26 23:11:19
【问题描述】:

我创建了一个具有功能的简单动态 Firebase 托管,部署时一切正常,但在本地提供页面时却不行。 这是firebase serve的日志

i  functions: Preparing to emulate functions.
i  hosting: Serving hosting files from: public
✔  hosting: Local server: http://localhost:5004

✔  functions: serveLandingPage: http://localhost:5001/zonaskripsi18/us-central1/serveLandingPage

正如我们所见,控制台和firebase-debug.log 中都没有错误日志,但是当我打开http://localhost:5004 时它显示An internal error occurred while connecting to Cloud Function "serveLandingPage"

这是firebase.json

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint"
    ]
  },
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "/**",
        "function": "serveLandingPage"
      }
    ]
  }
}

这是截图:

【问题讨论】:

  • 请使用 firebase.json 中的配置编辑问题。
  • 嗨史蒂文森,我已经添加了 firebase.json 的内容
  • 查看您的云功能日志。它可能取决于仅服务器的配置/功能。

标签: firebase firebase-hosting firebase-cli


【解决方案1】:

Firebase 最近本地服务器出现问题,只需部署它,然后运行它来测试它

【讨论】:

    【解决方案2】:

    如果您的函数项目是打字稿,那么您在提供本地主机之前已将打字稿编译为 javascript 文件。

    cd functions 
    tsc
    

    【讨论】:

      猜你喜欢
      • 2019-11-09
      • 2019-11-23
      • 2020-06-13
      • 2018-11-12
      • 1970-01-01
      • 2020-10-02
      • 2020-12-18
      • 2018-10-31
      • 2020-08-13
      相关资源
      最近更新 更多