Unity WebGL file loading blocked due to MIME type mismatch,Unity WebGL file blocked due to MIME mismatch.

I am building a WebGL game with the following setting:

  • Gzip compression
  • Optimize for speed
  • No decompression fallback
  • No data caching.

But I keep getting this error from the Chrome Javascript console:

The resource from “…/Build/WEBBUILD.framework.js.gz” was blocked due to MIME type (“application/x-gzip”) mismatch (X-Content-Type-Options: nosniff).

Here is my .htaccess configuration: (from the Unity manual here)

IfModule mod_mime.c

RemoveType .gz

AddEncoding gzip .gz

AddType application/octet-stream .data.gz

AddType application/wasm .wasm.gz

AddType application/javascript .js.gz
AddType application/octet-stream .symbols.json.gz

I have been trying to solve this for hours but still have no clue. Help, please.

@NenoSun !
Hi I’m facing error like that your facing
how to solve this error ?
will you help me to sort out t his error?
this is my Gmail : bsse386@gmail.com
I’m waiting for your response

Not sure if it’ll apply to a build that’s not using compression fallback, but I was getting the same error as you - only thing I found that seemed to do anything was adding ForceType application/javascript to the .js.gz files (courtsey of opertoonist).

Here’s a copy of my working .htaccess file, in case it helps:

#enable cached data to be read
Header set Content-Security-Policy "worker-src 'self' blob:; script-src 'self' blob:;"

<IfModule mod_mime.c>

# compression disabled?
AddType application/wasm .wasm
AddOutputFilterByType DEFLATE application/wasm

# support for compressionfallback option
AddEncoding gzip .unityweb

# Gzip support
<Files *.js.gz>
	AddType application/javascript .gz
	AddEncoding gzip .gz
	ForceType application/javascript
<Files *.wasm.gz>
	AddType "application/wasm" .gz
	AddEncoding gzip .gz

<Files *.data.gz>
	AddType "application/octet-stream" .gz
	AddEncoding gzip .gz

# brotli support
<Files *.js.br>
	AddType "text/javascript" .br
	AddEncoding br .br

<Files *.wasm.br>
	AddType "application/wasm" .br
	AddEncoding br .br

<Files *.data.br>
	AddType "application/octet-stream" .br
	AddEncoding br .br


Build Publishing Settings used were:

  • compression format: gzip
  • files as hashes: no
  • data caching: yes
  • debug symbols: no
  • decompression fallback: yes