微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法在 runcloud nginx 服务器上解决 wasm/unityweb 错误

如何解决无法在 runcloud nginx 服务器上解决 wasm/unityweb 错误

网站托管在 Ubuntu 18 服务器上 由 runcloud.io 管理 PHP 7.4 runcloud 的 Nginx 认配置。

我们在临时服务器上部署了一个 webgl 构建,并且无法在不引发控制台错误的情况下加载它:

You can reduce your startup time if you configure your web server to host .unityweb files using gzip compression.

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

falling back to ArrayBuffer instantiation

我创建了以下 Nginx 配置文件

location ~ .(wasm)$ {
    add_header content-encoding gzip;
    add_header Content-Type application/wasm;
}

location ~ .(unityweb)$ {
    add_header content-encoding gzip;
    add_header Content-Type application/octet-stream;
}

location ~ .(data.unityweb)$ {
    add_header content-encoding gzip;
    add_header Content-Type application/octet-stream;
}

location ~ .(wasm.framework.unityweb)$ {
    add_header content-encoding gzip;
    add_header Content-Type application/octet-stream;
}

include /etc/Nginx-rc/mime.types;
types {
    application/wasm wasm;
}
default_type application/octet-stream;
    
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types application/wasm application/octet-stream text/plain text/css text/xml application/json application/javascript application/xml+RSS application/atom+xml image/svg+xml;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。