Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to add wasm(WebAssembly)and etc content-type? #450

Closed
PlumpMath opened this issue Nov 2, 2021 · 7 comments
Closed

how to add wasm(WebAssembly)and etc content-type? #450

PlumpMath opened this issue Nov 2, 2021 · 7 comments

Comments

@PlumpMath
Copy link

I'm using ring.middleware.cors with unity3d wasm.

error:
wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.

warning:
HTTP Response Header "Content-Type" configured incorrectly on the server for file Build/MyGame.wasm , should be "application/wasm". Startup time performance will suffer.

(def ring-middle
(-> ROUTE/my-route
RING-MIDDLEWARE-JSON/wrap-json-body
RING-MIDDLEWARE-JSON/wrap-json-response
(RING-MIDDLEWARE-DEFAULTS/wrap-defaults
RING-MIDDLEWARE-DEFAULTS/site-defaults)
(RING-MIDDLEWARE-CORS/wrap-cors
:access-control-allow-credentials "true"
:access-control-allow-origin [#".*"]
:access-control-allow-headers #{"accept"
"accept-encoding"
"accept-language"
"authorization"
"content-type"
"origin"}
;; I want to add mime-types. "content-type:... "application/wasm br gz javascript" ... etc
:access-control-allow-methods [:get :put :post :delete :options])
))

@weavejester
Copy link
Member

Take a look at the ring.middleware.content-type/wrap-content-type middleware function. You can customize it by supplying your own mimetype map.

@PlumpMath
Copy link
Author

PlumpMath commented Nov 5, 2021

Thanks for the hint. But it doesn't work. When loading js from the html side, the address… Do I have to wrap the route by pulling out unity in advance? And when I go to the map and set content-type as the key and application/wasm as the value, the result is the same. The webgl page itself doesn't use index.html but loads unity webgl js from hiccup so I'm not sure what to do anymore. So I wonder if this suspicion is correct... (Actually, the program runs without problems. I just want to make sure I catch errors and warnings.)

@weavejester
Copy link
Member

Can you show me what you're doing when you say it doesn't work?

Also, how are you serving the wasm files? I assume as a public resource?

@PlumpMath
Copy link
Author

I can't upload the project as it is because will work, so I'll make a simple example and upload it. Please understand that it may be late. thank you.

@PlumpMath
Copy link
Author

PlumpMath commented Mar 4, 2022

It's so late, I'm sorry.
work is too busy; I was busy with other things.

After a few months of work end it,
and
as soon as possible I was thinking of uploading example at this rest time.

For Unity webgl compilation, there are two ways to compress wasm once (br and gzip method).
This is an uncompressed build.

Please take a look, and I hope you catch the error by adding content-type: .
thank you. @weavejester

@weavejester
Copy link
Member

I've been waiting for you to upload the example. There doesn't seem to be one linked or attached to the issue.

@PlumpMath
Copy link
Author

hmm i'm solve! sorry~. ;;

unity webgl build gzip & compression fallback? (check)
That way I don't have to deal with it.

And I'm not sure if this has any effect...
https://gist.github.com/martintrojer/841d6712a432380fe97c

Later, not unity wasm, other c++ or rust or godot (tools I want to deal with)
If a problem occurs in ... (I hope do not think again, but the web is too difficult for me...)
thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants