Firebase hosting custom headers not working

不打扰是莪最后的温柔 提交于 2021-01-27 07:31:19

问题


I deploy a static site on firebase hosting with some header configuarations. But I some of my headers doesn't appear after the site deployed.

I tried change the value of Cache-Control header and it works. But X-Frame-Options,Content-Security-Policy,X-Content-Type-Options doesn't.

firebase.json:

{
    "hosting": {
        "public": "public",
        "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
        "headers": [
            {
                "source": "**/*.@(html)",
                "headers": [
                    {
                        "key": "Cache-Control",
                        "value": "max-age=3600"
                    },
                        {
                        "key": "X-Frame-Options",
                        "value": "SAMEORIGIN"
                    },
                    {
                        "key": "Content-Security-Policy",
                        "value":
                            "script-src 'self' 'unsafe-inline' cdnjs.cloudflare.com; style-src 'self' 'unsafe-inline' cdnjs.cloudflare.com"
                    }
                ]
            },
            {
                "source": "**/*.@(jpg|jpeg|gif|png|ico|svg)",
                "headers": [
                    {
                        "key": "Cache-Control",
                        "value": "max-age=2592000"
                    }
                ]
            },
            {
                "source": "**/*.@(js|css)",
                "headers": [
                    {
                        "key": "Cache-Control",
                        "value": "max-age=2592000"
                    }
                ]
            },
            {
                "source": "**/*",
                "headers": [
                    {
                        "key": "X-Content-Type-Options",
                        "value": "nosniff"
                    }
                ]
            }
        ]
    }
}

Actual response header I get:

来源:https://stackoverflow.com/questions/49646417/firebase-hosting-custom-headers-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!