I'm trying to host a static website using AWS S3. The website contains, among other things, some WebAssembly code for a simple client-side game.
But when I try to import my WebAssembly from a JavaScript file, I get the following error:
Loading module from “http:/[REDACTED].s3-website-us-east-1.amazonaws.com/pkg/my_wasm_bg.wasm” was blocked because of a disallowed MIME type (“binary/octet-stream”).
I Googled this, and my understanding of the problem is that S3 sets the X-Content-Type-Options: nosniff
header on its internal HTTP requests, so that my JS can't import any files whose type is not a JavaScript MIME type. Since binary/octet-stream
is not a JavaScript MIME type, the import request is blocked.
How can I overcome this problem, and get my JS file to successfully import my WebAssembly within AWS S3?