unity webgl HTTP Response Header “Content-Type“ configured incorrectly on the server for file Build/

官方说明

(1):WebAssembly 串流的服务器配置 - Unity 手册

(2):Unity - Manual: Server configuration code samples

下面以 nginx 部署为例

mime.types 配置文件添加 类型。

    application/wasm                                 wasm;

如图:

nginx.conf 配置文件 在http里面添加

include       mime.types; 

如图:

修改完成 重启nginx 服务,标头黄色警告就没有了。

Apache 只需添加文件到Build文件夹

 .htaccess

内容:

# This configuration file should be uploaded to the server as "<Application Folder>/Build/.htaccess"
# This configuration has been tested with Unity 2020.1 builds, hosted on Apache/2.4
# NOTE: "mod_mime" Apache module must be enabled for this configuration to work.

# The following lines are required for builds without decompression fallback, compressed with gzip


<IfModule mod_mime.c>

<FilesMatch "[^.]+\.data.gz$">
  Header set Content-Type "application/octet-stream"
  Header set Content-Encoding "gzip"
</FilesMatch>

<FilesMatch "[^.]+\.js.gz$">
  Header set Content-Type "application/javascript"
  Header set Content-Encoding "gzip"
</FilesMatch>

<FilesMatch "[^.]+\.wasm.gz$">
  Header set Content-Type "application/wasm"
  Header set Content-Encoding "gzip"
</FilesMatch>

<FilesMatch "[^.]+\.gz$">
  Header set Content-Encoding "gzip"
</FilesMatch>

<FilesMatch "[^.]+\.wasm$">
  # Header set Content-Encoding "gzip"
  Header set Content-Type "application/wasm"
</FilesMatch>

</IfModule>

IIS 配置

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值