Unable to run local Unity WebGL (file:// url) All browsers, except Edge!

Hello. I’ve got a problem with launching my games made with Unity in a browser.

Or more specifically, games embedded in HTML pages on my computer don’t launch at all. And all I get is this message:

It seems your browser does not support running Unity WebGL content from file:// urls. Please upload it to an http server, or try a different browser.

This happens in Firefox, Google Chrome, Opera, Internet Explorer. Only in Microsoft Edge, my games are still working. I think three or four days back everything was fine - I’ve launched some of my games. But now, here is this.

So. What the hell is happening? How do I fix the problem?

3 Likes

The same story. After updating FireFox to ver 68

for FireFox this advice helped me:
change “privacy.file_unique_origin” to “false” in about:config

(from here: http://forums.mobirise.com/discussion/21485/issues-with-latest-firefox-68-0-previewing-sites-locally)
4768970--453800--2019-07-21_16-33-08.png

16 Likes

I have the same story. All browsers were working before with WebGL. I’m unsure why it’s saying it’s not supported now. All my browsers are up to date too.
I might have to download Firefox then.

Same problem here. And I just completely re-insalled firefox. No luck.

The same problem with my WebGL demo, Does anyone succeed?

If you do build and run unity starts a small server in the background that is hosting the webpage and the webgl export so you can access it via your localhost adress.
That you can not just open the file in your webbroser is because most of the major browser do value the users security more than the super slim chance that you might be opening a local html file.
If you like to host the file on your pc more permanently you can install a lightweight webserver to host your webgl build.
(my personal preference is XAMPP )

1 Like

This works! thank you very much.

1 Like

Install npm, a package manager, in your machine.
Them install a local server package (local-web-server - npm)

Open CMD inside the build folder and run ws

3 Likes

One way to solve this is after building your project:

  • Sign-in to your Account inside Unity Editor
  • Select Window > Share WebGL Game , from the top-menu
  • Share your project

A simple way to test your webGL game locally is using a local server like XAMPP.

Save a copy of your game build on xampp\htdocs folder. Starts Apache module in XAMPP control panel, and acess your game by an URL like this:

http://localhost//

This worked, Thank you!

1 Like

Hey dude, XAMPP may be a good choice but why not try to start an HTTP server in a simple way?

Just open your terminal and go into your directory (where the HTML file lies), and start the server using one of the commands below.

python -m CGIHTTPServer 8360
python -m http.server --cgi 8360
python3 -m http.server --cgi 8360

This will open the port for you.

Then direct your browser to http://localhost:8360/YOURFILENAME.html
The default one would usually be index.html :wink:

That’s probably the easiest way to do it.
Once you have your server running on local host, we can use https://ngrok.com/ with the same server port in order to access the build over the internet :slight_smile:

This solution worked for me. But not any longer - now even with “privacy.file_unique_origin” to “false” in about:config the same error.

2 Likes

:frowning:

These instructions were found in Dr. Tim Chamillard’s game development course:

Firefox (recommended browser for running WebGL)

  • Type about:config in the navigation bar
  • Search for the security.fileuri.strict_origin_policy parameter
  • Click that parameter to change it to false

Chrome

  • Add a shortcut to Chrome on your desktop if you don’t have one
  • Right click the shortcut and select Properties
  • Select the Target text box, go to the end, add a space and add --allow-file-access-from-files
  • Double-click the index html file for the WebGL build and copy the URL in the navigation bar when the browser opens
  • Close the browser
  • Start the browser using the shortcut, paste in the URL you copied in Step 4 and press enter

Microsoft Edge

No need to do anything, WebGL builds work fine.

Safari

  • Enable the develop menu using the preferences panel, under Advanced → “Show develop menu in menu bar”
  • From the safari “Develop” menu, select “Disable local file restrictions”
1 Like

try npm method in this article SIMMER.io

Just Build and Run from Unity, it will launch a small web server locally.

OLD info does not work in 7/7/2022 edge is not working firefox also not working with local WebGL

Do you mean via file:// url? Or from Unity with Build and Run