Skip to main content

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

CORS issue

A topic by TobidoT created Apr 10, 2020 Views: 311 Replies: 1
Viewing posts 1 to 2
Submitted

Maybe i am wrong here with this question, but 

During this JAM i downloaded the itch.io client for the first time and i have enjoyed quite a few game through it.
I also installed the game i have submitted to this JAM via the client and it was working.
Just now when i made a bigger update where i read levels from images i provide within the zip folder, i have a CORS issue.


https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getImageData

SecurityErrorThe canvas contains or may contain pixels which were loaded from an origin other than the one from which the document itself was loaded. To avoid SecurityError being thrown in this situation, configure CORS to allow the source image to be used in this way. See Allowing cross-origin use of images and canvas.

This works via the webbrowser, but not when i locally install it through the client.
I am not 100% sure if there is a workaround, i haven't yet read all about it. 

So maybe i will find a solution myself, i just thought if someone already knows about this, it could go faster.

Submitted

tldr; i have solved the issues.

So to summarize :

I managed to bypass the CORS issue by writing a script wich would convert the images into javascript files that hold huge arrays of the levels (wich are more than 7 times as big as the original images).
Directly including it into the program meant, there was no cross origin request anymore and the game worked from the local directory again.

But as i updated the game on itch.io and reinstalled it through the client it just showed a blank page.
Turns out you have to restart the whole itch.io client, in order to test a new version of your own game (at least with an html5 setup).

Is it only me that had that many problems to get my projects running in the itch.io client, or is no one realy using the client?