WebAssembly file - sending correct content type
I was creating a project where I used emscripten to build C/C++ code into asm.js or WebAssembly to run in browser (together with classic JavaScript code). After deploying to web server, although everything worked, I encountered some warnings about incorrect MIME type of the .wasm file.
In Chromium, the warning was:
In Firefox, it looked a little bit different:
The solution is sending correct Content-Type
header for the .wasm file:
When sending the file dynamically (e.g. from PHP), it can be easily done.
But my web application was only a bunch of static files and I did not want to bring any unnecessary complications to it by adding server-side code.
Creating .htaccess
file in the directory where the .wasm file resides helped:
Thankfully, my web hosting has not disabled this functionality or .htaccess
completely.