html 中的 firebase 跨源策略 godot 游戏

问题描述 投票:0回答:1

我已在 Firebase 托管上托管了所有游戏,如果您尝试去玩 url godot 游戏中的游戏,则可以。这是链接:https://api.technoviumunlimited.nl/games/Ag7KtmdKNIG0va7bi1ne/ 如果我尝试从 iframe 加载它:https://technoviumunlimited.nl/games/Ag7KtmdKNIG0va7bi1ne 我收到错误:

Error
The following features required to run Godot projects on the Web are missing:
Cross Origin Isolation - Check web server configuration (send correct headers)
SharedArrayBuffer - Check web server configuration (send correct headers)

这是我的 firebase.json

{
  "hosting": {
    "public": "public", 
    "headers": [
      {
        "source": "/games/**",
        "headers": [
          {
            "key": "Cross-Origin-Embedder-Policy",
            "value": "require-corp"
          },
          {
            "key": "Cross-Origin-Opener-Policy",
            "value": "same-origin"
          },
          {
            "key": "Cross-Origin-Resource-Policy",
            "value": "cross-origin"
          },
          {
            "key": "SharedArrayBuffer",
            "value": "true"
          }
        ]
      },
      {
        "source": "/**/*.wasm",
        "headers": [
          {
            "key": "Cross-Origin-Resource-Policy",
            "value": "cross-origin"
          },
          {
            "key": "SharedArrayBuffer",
            "value": "true"
          }
        ]
      },
      {
        "source": "/**/*.css",
        "headers": [
          {
            "key": "Cross-Origin-Resource-Policy",
            "value": "cross-origin"
          },
          {
            "key": "SharedArrayBuffer",
            "value": "true"
          }
        ]
      },
      {
        "source": "/**/*.worker.js",
        "headers": [
          {
            "key": "Cross-Origin-Resource-Policy",
            "value": "cross-origin"
          },
          {
            "key": "SharedArrayBuffer",
            "value": "true"
          }
        ]
      },
      {
        "source": "/**",
        "headers": [
          {
            "key": "Cross-Origin-Resource-Policy",
            "value": "cross-origin"
          },
          {
            "key": "SharedArrayBuffer",
            "value": "true"
          }
        ]
      }
    ],
    
    
    "rewrites": [
      {
        "source": "/games/**",
        "destination": "/index.html"
      },
      {
        "source": "**",
        "function": "app",
        "region": "us-central1"
      }
    ]
  },
  "functions": [
    {
      "source": "functions",
      "codebase": "default",
      "ignore": [
        "node_modules",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ]
    }
  ]
}
firebase-hosting godot4
1个回答
0
投票

要在加载的 iframe 内启用 SharedArrayBuffer,请将

allow="cross-origin-isolated"
附加到
<iframe>

© www.soinside.com 2019 - 2024. All rights reserved.