Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Spin up a local web server to serve downloaded HTML-type games?

A topic by ꜱᴩʀɪᴛᴇ➀ created Apr 09, 2018 Views: 881 Replies: 4
Viewing posts 1 to 3
(2 edits)

Some HTML5 games like those made in Godot have trouble running when directly opened locally.

Right now, the itch.io client seems to just download the files and extract them to a directory then opens it directly from there. My suggestion is, when the user tries to launch a downloaded HTML game, spin up a local web server in that game's folder and load the path

http://localhost:<somerandomportforthegame>

in the pop out window instead. Of course when the game is closed, the local web server should be terminated as well.

Hey there,

Can you link to a game that isn't working?

The app doesn't "just open the directory" using the file: protocol - it registers a custom protocol that serves the game's files, see:

If you link me to a game I can investigate further :)

(4 edits)

Sure, here's a test I uploaded. It's set to restricted but I'm sure admins can still see it. 😋 made it public for less hassle

https://sprite-1.itch.io/html5test

It works when opened on a browser but when I try to open it from the client, it doesn't load. I thought it was serving the files directly using `file://` because this same behavior (it not working) can be observed when opening the HTML file of the game locally. 

(+2)

Gave it a spin, and it seems the reason it's buggy has nothing to do with the protocol it's loaded over :)


It appears the `navigator.languages` array is empty in electron's browser window context.

Apparently it's a known issue, that we can work around: https://github.com/electron/electron/issues/11053

It'll have to wait for itch v25 though (the next big release). I've opened an issue here to track our progress: https://github.com/itchio/itch/issues/1758

Nice, thanks! Looking forward for 25 to drop. 🎉