Reputation: 191
I have built a blazor webassembly site which I host on an ubuntu server using nginx. The configuration of the site in nginx is like this:
server {
server_name app.mysite.local;
root /srv/sites/app.mysite.local;
index index.html;
}
I published the site using visual studio to a local folder and copied the /dist folder to the root of /srv/sites/app.mysite.local. The site is now working on app.mysite.local but I get the folowing error messages:
WASM: wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.
WASM: falling back to ArrayBuffer instantiation
I tried adding 'application/wasm wasm' to the files /etc/mime.types and /etc/nginx/mime.types and restarted the server but without any effect. I don't know if these error messages are connected.
What I also noticed is when I go to /account/companyname using the menu on the index page, the page is displayed but I when I type the url app.mysite.local/account/companyname in the address bar I get an nginx 404 error. Maybe this is solved when I solve the mime type issue but I don't know that for sure.
Can anybody help me solving the mime type issue? Let me know if you need more information. Thanks in advance!
Upvotes: 5
Views: 6352
Reputation: 17434
You don't use the dist folder:
You should publish the application using dotnet publish -c Release
and copy the folder bin\Release\netstandard2.1\publish\wwwroot to /srv/sites/app.mysite.local
The nginx.conf should be:
events { }
http {
include mime.types;
types {
application/wasm wasm;
}
server {
listen 80;
location / {
root /srv/sites/app.mysite.local;
try_files $uri $uri/ /index.html =404;
}
}
}
Upvotes: 11