0

我正在尝试autoplay通过为文件中的标头设置配置来整理主机级别的策略firebase.json。这是我的主机的片段,它有两个目标production和“暂存”:

"hosting": [
    {
      "target": "staging",
      "public": "build",
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ],
      "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
      ],
      "headers": [ {
        "source": "**/*.@(mp3|wav)",
        "headers": [ {
          "key": "Feature-Policy",
          "value": "autoplay *"
        },
        {
          "key": "Permissions-Policy",
          "value": "autoplay *"
        } ]
      } ]
    },
    {
      "target": "production",
      "public": "build",
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ],
      "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
      ],
      "headers": [ {
        "source": "**/*.@(mp3|wav)",
        "headers": [ {
          "key": "Feature-Policy",
          "value": "autoplay *"
        },
        {
          "key": "Permissions-Policy",
          "value": "autoplay *"
        } ]
      } ]
    }
  ],

因此,从我在这里阅读的文件中: https ://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy 和 https://firebase.google.com/docs/hosting/完整配置

这应该是正确的方法:

"source": "**/*.@(mp3|wav)",
        "headers": [ {
          "key": "Feature-Policy",
          "value": "autoplay *"
        },

在这个阶段,我只是在推送任何内容之前寻求确认和建议。

4

0 回答 0