【问题标题】:Firebase Hosting re-writes not working on non-us-central1 regionFirebase 托管重写不适用于非 us-central1 区域
【发布时间】:2021-04-10 17:11:58
【问题描述】:

我已将 next.js 应用部署到 Google Cloud,并且正在使用 Functions 和 Hosting。

我最近尝试将所有内容移至northamerica-northeast1 区域。我重新部署了所有函数,将.region("northamerica-northeast1") 放在我所有函数的开头,如here 所示。这成功更新了我所有函数的位置。

不过,我也使用一个函数来为我的 next.js 应用程序提供服务:

const server = functions.https
  .onRequest((request, response) => {
    return app.prepare().then(() => handle(request, response));
  });

然后我重写了这个函数的所有 URL:

  "hosting": {
    "target": "webapp",
    "public": "public",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "rewrites": [
      {
        "source": "**",
        "function": "nextjs-server"
      }
    ]
  },

这是 Google Cloud 上所有标准的 next.js,我已经这样做了 2 年多。但是,当我使用以下方法将功能移动到新区域时:

const server = functions
.region("northamerica-northeast1")
.https
.onRequest((request, response) => {
    return app.prepare().then(() => handle(request, response));
  });

看来重写不再有效。该函数已更新,但当我访问该站点时,我得到一个 404。然后,当我将该函数移回默认区域(通过删除 .region())时,它又可以正常工作了。

我尝试了 3 个当前项目,都是一样的。

最后,我尝试创建一个全新的项目并部署到northamerica-northeast 区域(如前所述),并使用其中的区域代码推送功能......所以我的项目从未在除@ 之外的任何地方托管987654328@ 仍然失败。但是,通过删除该区域,重新写入再次开始正常工作,我可以看到该站点。即使站点的整个其余部分都在 northamerica-northeast1 区域中,并且只有这一个服务器功能移动到默认区域。

我相信这是在谷歌云上重写的一个错误?还是我遗漏了什么,或者某处的某个文档说该地区无法进行重写?

【问题讨论】:

    标签: firebase google-cloud-platform google-cloud-functions firebase-hosting


    【解决方案1】:

    如果您想同时使用托管和云函数,函数位于us-central1

    Firebase 托管仅在 us-central1 中支持 Cloud Functions。

    Serve dynamic content and host microservices with Cloud Functions

    【讨论】:

    • 呃,好吧错过了。感谢您的信息
    猜你喜欢
    • 2023-02-18
    • 2020-01-29
    • 2019-11-01
    • 2014-10-14
    • 2020-10-12
    • 2021-05-01
    • 2019-12-24
    • 2021-07-03
    • 2019-01-17
    相关资源
    最近更新 更多