根据 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/