gpt4 book ai didi

Firebase 托管不发送自定义 HTTP header

转载 作者:行者123 更新时间:2023-12-02 09:43:59 24 4
gpt4 key购买 nike

根据Firebase Hosting docs ,我应该能够在从服务器收到的响应上设置自定义 header 。我试图在所有 html 文件上设置 X-Frame-Options header ,但服务器根本不想发送此 header !这是我的 firebase.json 文件,如果我做错了什么,请告诉我:

{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"headers": [
{
"source": "**/*.html",
"headers": [
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
}
]
}
]
}
}

最佳答案

我刚刚在同一个问题上经历了很多尝试和错误。我注意到 firebase documentation 中有一小部分:

A source value that Hosting matches against the original request path, regardless of any rewrite rules.

如果您的设置与我的类似,您的 firebase.json 文件中可能有以下内容:

  "rewrites": [{
"source": "**",
"destination": "/index.html"
}]

但是,虽然您可能返回index.html,但原始请求路径只是“/”,因此在 header 部分使用:

"source": "/"

这对我有用。

关于Firebase 托管不发送自定义 HTTP header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48657320/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com