The purpose
This is a memo on how to fix an error that prevented the app from starting when I opened the HTML file after building a Unity project for WebGL.
Errors and solutions
Failed to download file
Error

Failed to download file Build/buildtestweb.framework.js.unityweb. Loading web pages via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host Unity content, or use the Unity Build and Run option.
Or
Failed to download file Build/buildtestweb.framework.js.br. Loading web pages via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host Unity content, or use the Unity Build and Run option.
Solution
You’ll see this error if you try to open the index.html
file directly.
To fix this, you can either set up a local server using the methods below or upload the file to a real server.
Unable to parse
Error

Unable to parse Build/buildtestweb.framework.js.br! This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: br" present. Check browser Console and Devtools Network tab to debug.
Solution
Go to the Edit
menu and click Project Settings...
to open the settings window.
On the left-hand side, choose the Player
section and then go to Publishing Settings
.
Check the box for Decompression Fallback
.
Close the settings window and perform the build again.

Ticking this box changes the file extension from .br
to .unityweb
. (While this only changes the extension and not the file’s content, it can sometimes cause issues with readability. The errors suggest this might also be fixed by adjusting server settings.)
Unable to parse (2)
Error

Unable to parse Build/buildtestweb.framework.js.unityweb! The file is corrupt, or compression was misconfigured? (check Content-Encoding HTTP Response Header on web server)
Solution
Your files may be corrupted. Please check them.
For example, .unityweb
files must be uploaded in binary mode. If you upload them in ASCII mode, the error above will occur.
comment