firebase - 如何绕过 Firebase Hosting 的默认 Vary on Authorization header

标签 firebase firebase-hosting

根据 Firebase Hosting 的文档: https://firebase.google.com/docs/hosting/functions#when_is_cached_content_served

Firebase Hosting automatically ensures that an appropriate Vary header is set on your response for common situations. This includes making sure that any session cookie or authorization header that you're using is made part of the cache key, which prevents accidental leaks of content.

Firebase Hosting 会自动将“授权” header 放入 Vary 中。

但是,某些 API 确实需要获取“授权” header 并确定是否需要在 Firebase 托管中缓存响应。

我可以知道如何使 Firebase Hosting 不因授权 header 而变化吗?谢谢。

最佳答案

[注意,我是一名从事托管工作的 Firebaser]

对于通过 Firebase 托管连接的 Firebase 函数,您无法更改返回的默认 Vary header 。如果函数向 Vary header 添加其他值,这些值将被包含在内,但不能覆盖默认值。

[根据想法进行编辑...]

可能(这是一个很大的可能,我还没有尝试过)能够直接调用函数的端点,而不是通过托管,如果您真的不这样做的话不希望 Vary header 包含 Authorization。您必须处理CORS和相关的事情,但您可以更好地控制它。

因为托管的好处是它位于 CDN 后面,所以它需要一种良好(安全)的方式来缓存信息,而授权对此至关重要。如果您想自己处理其中一些问题,直接调用函数可能是最好的选择。

关于firebase - 如何绕过 Firebase Hosting 的默认 Vary on Authorization header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53984935/

相关文章:

ios - Firebase 多个观察者复制单元格

cordova - PhoneGap 移动应用中的 Firebase URL 安全性

java.lang.IllegalArgumentException : Response must include generic type (e. g.,响应<字符串>)

ios - Firebase 和 GeoFire fetch double 将新帖子添加到 Collection View

firebase - 使用 Firebase 托管时 Web 应用程序中的灰色区域

javascript - 我可以将 Dart 编译的 JS (JavaScript) 用于静态网站的 Firebase 托管吗

firebase - 同一触发器的多个云函数会导致问题吗? #AskFirebase

firebase - 重写从除 us-central1 以外的其他区域的托管到云功能的路由

firebase - 我的网站在 firebase 中部署后未显示如何解决此问题

firebase - 将 Firebase SSL 托管用于两个不同的 Web 应用程序