Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Your game isn't kept as a zip file on the server. It's unpacked. You can load any file via AJAX, with a relative path.

I get a cross origin request error when I try to use AJAX (XMLHttpRequest) locally on my machine. I would assume that it wouldn't work on itch.io either, Am I right about that? If so, what am I doing wrong?

Of course you're getting that error when opening a local file directly. You need to use a web server. On itch.io you already have one by definition, so it should work.

Thanks for your help! What would be the best way to be able to run the same code either on my own machine or through itch.io, and have it work either way (if there is one)?

Use Apache HTTP Server or something similar to run it from local host.

This is what I use to turn a folder on my machine into a localhost:3000 site: https://www.npmjs.com/package/http-server