title: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'
body: <p>I'm trying to load a .wasm file using the fetch api on Chrome , and serving a html file using express. But chrome does not let me load the file: </p>
  
  <p>'Uncaught (in promise) TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.'</p>
  
  <p>Here is my files:</p>
  
  <p>/public/index.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en" dir="ltr"&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;script type="text/javascript"&gt;
            WebAssembly.instantiateStreaming(fetch('http://localhost:3000/simple.wasm'))
        .then(obj =&gt; {
         console.log(obj.instance.exports.add(1, 2));  // "3"
        });
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Served by Express: </p>
  
  <p>/index.js</p>
  
  <pre><code>const express = require('express')
  express.static.mime.define({'application/wasm': ['wasm']})
  var app = express();
  
  app.use('/', express.static('public'));
  
  app.listen(3000, function () {
    console.log('Example app listening on port 3000!')
  })
  </code></pre>
  
  <p>Can i add a new mime type to express when serving a .wasm file? 
  Or allow chrome to accept it? 
  I dont have any idea for how to solve it ^^</p>
  
  <p>See: <a href="http://kripken.github.io/emscripten-site/docs/compiling/WebAssembly.html" rel="noreferrer">http://kripken.github.io/emscripten-site/docs/compiling/WebAssembly.html</a></p>
  
  <pre><code>Web server setup
  To serve wasm in the most efficient way over the network, make sure your web server has the proper MIME time for .wasm files, which is application/wasm. That will allow streaming compilation, where the browser can start to compile code as it downloads.
  
  In Apache, you can do this with
  
  AddType application/wasm .wasm
  Also make sure that gzip is enabled:
  
  AddOutputFilterByType DEFLATE application/wasm
  </code></pre>
  
  <p>Thank you everyone! </p>