【发布时间】:2020-08-17 05:00:51
【问题描述】:
我只想在请求来自 Google bot 用户代理时调用 firebase 函数。
目前我正在对每个 http 请求调用该函数。
- 请求进来
- 检查用户代理
- 用户代理是 Google 然后是
response.send("hello google") - 用户代理不是 Google 渲染来自 firebase 托管的 index.html。
request({uri: "http://example.com/index.html"},
function(error, response, body) {
res.send(body)
});
});
这将导致循环,因为该函数将从 Firebase 托管请求 index.html 文件,并且这样做将再次调用该函数。所以我认为只有当请求来自谷歌用户代理时才调用函数更好
这可能吗?有什么想法可以解决这个问题吗?谢谢!
【问题讨论】:
-
重定向到 example.com/index.html 不起作用?
-
会再次触发函数
标签: javascript firebase google-cloud-functions