0

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

我们在登台服务器上部署了一个 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;
4

0 回答 0