Skip to main content

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

Problem with CORS access restriction when downloading web game

A topic by Kaisky1911 created Jul 04, 2022 Views: 186
Viewing posts 1 to 1
(1 edit)

So I made this HTML5 Game in plain Javascript, in the browser it works fine. https://kaisky1911.itch.io/frankenmind However, when I try to play it in the itch hub, it will just run the game as if I open the index.html file in a Browser from my local file system without a webserver. That leads to Audiofiles not loading correctly, giving a CORS access restriction warning. I fixed this warning by setting audio.crossOrigin = "anonymous" for each audio file. However, doing that will cause an error when trying to play the Audio.

Access to audio at 'file:///C:/Users/profk/dev/Frankenmind/sounds/boulder.mp3' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.

Also, some audios work and others don't. Weird.

Does anyone know how to solve this?


Edit: I googled this quite a lot and it seems to be impossible to play audio files in the browser from the local filesystem unless you change a specific browser setting. Since the itch hub running web games seems to be just like a mini-browser I'm very surprised no one else had this issue yet.  Apparently, there is no problem using game engine web builds, but my game is made from scratch in HTML5 without any engine. I change this topic from "question" to "bug" now since I start to believe there is nothing I can do about it except hoping the itch hub runs webgames by starting a web server on localhost or will change this "setting" to access local audio files. For reference: https://stackoverflow.com/questions/31308679/mediaelementaudiosource-outputs-zer...

Kaisky

This topic has been auto-archived and can no longer be posted in because there haven't been any posts in a while.