Fixing Cross Origin Isolation and SharedArray Buffer for Godot game hosted on Firebase?

584 views Asked by At

I have tried multiple different solutions found online, but I keep running into the same 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)

I have chnaged firebase.json to

{
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  },
  "headers": [
    {
      "source": "**/.*",
      "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"
        }
      ]
    }
  ]
}

I have added these lines to my index.html:

<script>
        var module = new WebAssembly.Module(buffer);
        var instance = new WebAssembly.Instance(module, { js: { js: () => {} } }, {});
</script>
<script src="index.js" crossorigin="anonymous"></script>

To be honest I'm pretty lost. All I want is to my my webpage be the godot game from the index.html.

1

There are 1 answers

0
Christina On

You have a typo in your firebase.json. The headers array should be inside the hosting object.

In your case, remove the closing } on line 9 should fix it.

  "ignore": [
      ...
    ]
  },  # <-- delete this closing bucket
  "headers": [
...

For reference, this is what my firebase.json looks like.

{
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "headers": [ {
      "source": "**/*",
      "headers": [
        {
          "key": "Cross-Origin-Opener-Policy",
          "value": "same-origin"
        },
        {
          "key": "Cross-Origin-Embedder-Policy",
          "value": "require-corp"
        }
     ]
    } ]
  }
}

Tested with Godot 4.2.1, firebase 13.0.2, and Firefox 120.0.1.

P.S. I did not make any changes to my index.html.

ref: https://firebase.google.com/docs/hosting/full-config#headers