LoginSignup
2

More than 5 years have passed since last update.

Incorrect response MIME type. Expected 'application/wasm' エラーの 対応

Last updated at Posted at 2018-09-30

Rust × WebAssemblyのチュートリアルをやっていたら、ブラウザ上でこんなエラーに出くわしました。

Error importing `index.js`: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.

↓↓↓エラーのスクショ
スクリーンショット 2018-09-30 23.49.09.png

↓↓↓Response Headersはこんな感じでContent-Typeが無い
スクリーンショット 2018-09-30 23.48.54.png

サーバー側にMIME typeの設定を追加しましょう。

CentOS7の場合

$ vim /etc/mime.types

Vimやechoのリダイレクションなどで一番下にapplication/wasm wasmを追加

x-conference/x-cooltalk                         ice
x-epoc/x-sisx-app                               sisx
application/wasm                                wasm  

そしてサーバー再起動しましょう。
これで自分は正常にブラウザにMIME typeが送られて実行する事ができました。

↓↓↓ 追加後のChromeのResponse HeadersのContent-Typeはこんな感じ

スクリーンショット 2018-09-30 23.45.22.png

参考:https://github.com/mdn/webassembly-examples/issues/5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2