繁体   English   中英

如何在 ubuntu nginx 上为 blazor 站点提供正确的 mime 类型

[英]How to serve the right mime type for a blazor site on ubuntu nginx

我已经使用 nginx 在 ubuntu 服务器上构建了一个 blazor webassembly 站点。 nginx中站点的配置是这样的:

server {
    server_name  app.mysite.local;
    root         /srv/sites/app.mysite.local;
    index        index.html;
}

我使用 Visual Studio 将站点发布到本地文件夹,并将 /dist 文件夹复制到 /srv/sites/app.mysite.local 的根目录。 该站点现在正在 app.mysite.local 上运行,但我收到以下错误消息:

WASM:wasm 流编译失败:TypeError:无法在“WebAssembly”上执行“编译”:响应 MIME 类型不正确。 预期的“应用程序/wasm”。

WASM:回退到 ArrayBuffer 实例化

我尝试将 'application/wasm wasm' 添加到文件 /etc/mime.types 和 /etc/nginx/mime.types 并重新启动服务器但没有任何效果。 我不知道这些错误消息是否已连接。

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错误。 当我解决 mime 类型问题时,这可能会解决,但我不确定。

有人可以帮我解决 mime 类型的问题吗? 如果您需要更多信息,请与我们联系。 提前致谢!

你不使用好的 fodler:
您应该使用dotnet pusblish -c Release发布应用程序并将文件夹bin\Release\netstandard2.1\publish\wwwroot复制到/srv/sites/app.mysite.local

nginx.conf应该是:

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;
        }
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM