Firebase托管重定向到另一个子域保持查询和参数

发布于 2025-01-22 14:25:06 字数 276 浏览 0 评论 0原文

如何将调用调用到另一个子域,将所有请求保留为使用Firebase托管的原始请求。我可以在Web应用程序级别上做到这一点,但这将导致性能问题。

例如:

https://some.app.com/Route/param?= something

&ampt; tokOthOts

https://different.app.com/route.com/route/param?= something &to /代码>

How can I redirect calls to another subdomain, keeping all the request as the original using Firebase hosting. I could do it at web application level but this will lead to performances issues.

Ex :

https://some.app.com/route/param?=something&others

to

https://different.app.com/route/param?=something&others

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玻璃人 2025-01-29 14:25:06

我正在研究类似的事情,这是我目前作为firebase节点函数的尝试:

exports.redirectExample = functions.https.onRequest((req, res) => {
  const redirectDomain = "example.org";
  const subdomains = req.subdomains;
  if (subdomains) {
    const reverseJoinSubdomains = subdomains.reverse().join('.');
    res.redirect("https://" + reverseJoinSubdomains + "." + redirectDomain + req.path);
  } else {
    res.redirect("https://" + redirectDomain + req.path);
  }
});

我无法使它起作用,当我记录了req.subdomains时,即使我对此功能指出了多个记录子域,也是空的。可能由于这些服务器设置的方式而丢失了请求对象的子域。无论子域如何,我都会恢复到简单地转发到静态主机名,但是如果有人对req.subdomains在firebase函数中不起作用的答案,请让我们知道!

I was working on something similar, here is my current attempt as a firebase node function:

exports.redirectExample = functions.https.onRequest((req, res) => {
  const redirectDomain = "example.org";
  const subdomains = req.subdomains;
  if (subdomains) {
    const reverseJoinSubdomains = subdomains.reverse().join('.');
    res.redirect("https://" + reverseJoinSubdomains + "." + redirectDomain + req.path);
  } else {
    res.redirect("https://" + redirectDomain + req.path);
  }
});

I could not get this to work, when I logged req.subdomains it was empty even though I have pointed multiple A Record subdomains to this function. Perhaps subdomain on request object is lost due to the way these servers are setup, not sure. I'll revert to simply forward to a static hostname regardless of subdomain, but if anyone has an answer to why req.subdomains doesn't work in firebase functions please let us know!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文