Hello all,
I’ve been trying to build a simple game similar to patatap.com with animation and sound playing linked to keyboard input - with fade-ins on the animation using coroutines that scale alpha by deltaTime. When built as a standalone version, the program works as expected - however, when built as WebGL, I get this error when opening index.html:
(continued)
Apologies for the screenshots: I can’t figure out a way to copy and paste the error message, so it’s difficult for me to put this into a code block.
Upon investigation of the console, I find these errors:
Access to XMLHttpRequest at 'file:///C:/Users/justi/Documents/Code/Uncertain%20%20Tap/Builds/WebGL%20Final%20Build/Build/WebGL%20Final%20Build.data' 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.
Build/WebGL%20Final%20Build.data:1 Failed to load resource: net::ERR_FAILED
WebGL Final Build.framework.js:2 Fetch API cannot load file:///C:/Users/justi/Documents/Code/Uncertain%20%20Tap/Builds/WebGL%20Final%20Build/Build/WebGL%20Final%20Build.wasm. URL scheme must be "http" or "https" for CORS request.
doNativeWasm @ WebGL Final Build.framework.js:2
WebGL Final Build.loader.js:1 wasm streaming compile failed: TypeError: Failed to fetch
printErr @ WebGL Final Build.loader.js:1
WebGL Final Build.loader.js:1 falling back to ArrayBuffer instantiation
printErr @ WebGL Final Build.loader.js:1
WebGL Final Build.framework.js:2 Fetch API cannot load file:///C:/Users/justi/Documents/Code/Uncertain%20%20Tap/Builds/WebGL%20Final%20Build/Build/WebGL%20Final%20Build.wasm. URL scheme must be "http" or "https" for CORS request.
getBinaryPromise @ WebGL Final Build.framework.js:2
WebGL Final Build.loader.js:1 both async and sync fetching of the wasm failed
WebGL Final Build.loader.js:1 both async and sync fetching of the wasm failed
printErr @ WebGL Final Build.loader.js:1
WebGL Final Build.loader.js:1 failed to asynchronously prepare wasm: TypeError: WebAssembly.instantiate(): Argument 0 must be a buffer source or a WebAssembly.Module object
However, if I build and run directly from the editor, I find that all functions except for loading my animations function perfectly. Additionally, after refactoring my code to not use coroutines, I find the same behavior. It is worth mentioning that the animation database that I am using is loaded from Resources, and is relatively large compared to the sound database I am loading (also from Resources). However, I have little experience with WebGL exporting in particular, and any help as to what could be causing this error and if the problem could be fixed is much appreciated! Additionally, please let me know if there is any other code I can attach that would help diagnose the situation.
Thanks!
EDIT: It is also worth mentioning that I plan to upload this build to simmer.io as a hosting service - I’ve seen similar solutions relating to CORS issues that use PHP proxies and other such tools (if I’m not mistaken), but I won’t be able to use such workarounds as I’m planning to upload the build to a 3rd party hosting server.