Blog: Dokku and MIME types

I use Dokku to manage the various projects hosted on my domain, such as this website. It's worked pretty well so far, but I've had one issue while getting my 15 Puzzle solver hosted.

To host a static page using Dokku, Dokku has an official buildpack. To trigger it, it's as simple as creating an empty .static file in the root directory. However, if you happen to also host WebAssembly (.wasm) files, you may have encountered an invalid MIME type error:

TypeError: Incorrect response MIME type. Expected 'application/wasm'

Certain WebAssembly methods require that the file has the right MIME type. The buildpath's mime.types file, which maps file extensions to MIME types, lacks support for WebAssembly files.

However, the buildpack checks if there's a user provided mime.types file during compilation, and uses it instead of the default.

So, this can be fixed by supplying your own mime.types file in the root directory. Start out with an existing list (here's the one used by the buildpack), and add any additional types. For me, I only needed to add one line:

types {
    application/wasm                      wasm;

I've tested this on my Dokku instance with WebAssembly, but this method should work with any missing MIME type.