polypush135
Trying to serve a wasm file as a static asset from phoenix (cowboy) but need to set my content-type
As the title says, I’m trying to serve a static asset from Phoenix/Cowboy for local development but hitting a little snag as there is currently no mime type for wasm Add application/wasm as a valid mime type · Pull Request #35 · elixir-plug/mime · GitHub
The result is I get this console error while trying to load the wasm file.
Uncaught (in promise) TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'
The current content type I’m getting is content-type: application/octet-stream.
My question is how would if I can set this myself for the time being from phoenix, assume I can as I expect this to be an issue with cowboy?
Marked As Solved
NobbZ
Use the :content_types option for Plug.Static:
:content_types- custom MIME type mapping. As a map with filename as key and content type as value. For example:content_types: %{"apple-app-site-association" => "application/json"}.
Popular in Questions
Other popular topics
Latest Phoenix Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









