【问题标题】:Would URL rewrite make Firebase cloud function response come from my custom domain?URL 重写会使 Firebase 云功能响应来自我的自定义域吗?
【发布时间】:2021-04-19 12:46:33
【问题描述】:

Firebase 文档提到您可以使用自定义域通过 url 重写来提供云功能。

您可以使用重写从 Firebase 托管 URL 提供函数。 以下示例是使用提供动态内容的摘录 云函数。'

"hosting": {
  // ...

  // Directs all requests from the page /bigben to execute the bigben function
  "rewrites": [ {
    "source": "/bigben",
    "function": "bigben"
  } ]
}

云函数响应可以通过以下方式返回值以在 cookie 中设置:

res.cookie("session", sessionCookie, {
      expires: new Date(new Date().getTime() + expiresIn), // Add 2 weeks (in milliseconds) to the current epoch
      httpOnly: true,
      secure: true,
      sameSite: "none",
      domain: req.get("host")
    });

// Return an HTTP 204 NO CONTENT response
return res.sendStatus(204);

但在大多数浏览器中,不允许使用 3rd 方 cookie,仅允许 1 方。

我知道由于 url 重写,我可以使用我的自定义域调用云功能,但是响应如何,是考虑第一方还是第三方?

【问题讨论】:

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


    【解决方案1】:

    从浏览器的角度来看,cookie 将直接来自 Firebase 托管,因此该 cookie 将被视为第一方 cookie。请注意,rewrite 为了从 Firebase 托管 URL 提供云功能都发生在服务器端,因此解释了行为。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-26
      • 2021-04-22
      • 2021-06-22
      • 2018-05-26
      • 1970-01-01
      • 1970-01-01
      • 2020-06-04
      • 2021-09-04
      相关资源
      最近更新 更多