Search code examples
reactjsamazon-web-servicesrustwebassemblyaws-amplify

aws amplify not serving content-type for wasm


I've written a wasm module with wasm-pack in rust. I'm using it as part of a react SPA. I've published the wasm library to npm and everything works fine on my local machine. It also works on an ec2 instance; however when I deploy via aws Amplify, I get the following issue

Unexpected error in loadWasm. [Message: Response has unsupported MIME type]

The response header includes

content-type: text/html

for

https://master.d3447bi8c4sf9b.amplifyapp.com/ac0bae67a38fb31af71d.module.wasm

I've tried to edit the custom header yml a few different ways

customHeaders:
  - pattern: '*.wasm'
    headers:
      - key: Content-Type
        value: application/wasm

customHeaders:
  - pattern: '*.wasm'
    headers:
      - key: 'Content-Type'
        value: 'application/wasm'

I'm not sure if the wasm is being served from Amplify improperly or what. Any help would be appreciated


Solution

  • I also had this. As well as adding the mime type I added wasm to the Amplify "Rewrites and redirects" rules as below

    </^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json|wasm)$)([^.]+$)/>