WebGL cross-domain error when loading .mem file from remote

Hello,

I am trying to host the WebGL build files (.mem, .data and .js) in another server from my game’s website and there is a problem with the browser’s Cross-Domain restrictions.

I CAN load scripts from another server, because it is using Access-Control-Allow-Origin with ‘*’ on the remote server. When I used Webgl prior to version 5.3, there was no problem, and I don’t know why, since it also used XMLHttpRequest.

Error:

XMLHttpRequest cannot load
http://remoteServerName.com/webgl/Release/webgl.mem.
No ‘Access-Control-Allow-Origin’
header is present on the requested
resource. Origin
http://originServerName.com’ is
therefore not allowed access. The
response had HTTP status code 404.

Line of code of UnityLoader.js that makes the XMLHttpRequest to load and decompress the “webgl.mem” file:

function DecompressAndLoadFile(e,t,n){e+="gz";var o=new XMLHttpRequest;o.open("GET",e,!0)

Tha strange thing is that on later versions, when the loader was named fileloader.js and it didn’t have the DecompressAndLoadFile function, it was working fine and I could load all the files from remote server without any problem.

My question is: how can I modify the above code so that it will load the .mem file with success?

IMPORTANT: I can’t to host the .mem file at the same server, because of technical restrictions.

Thank you in advance.

Now the .mem file is correctly loaded, but there is an error with .data file from remote or from the same server. I can run the build from my PC, but when I host it to Google App Engine / Google Cloud Storage, the errors appear. I have tried to host the .data file on another server that accepts gzip using Unity’s .htaccess, but it does not work also.

Here is the URL of the project: http://6.animagolapp2.appspot.com/

Error:

loading webgl.data from cache
UnityLoader.js:1 pre-main prep time: 3767 msModule.printErr @ UnityLoader.js:1doRun @ blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:39(anonymous function) @ blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:39

UnityLoader.js:1 Invoking error handler due to
Uncaught TypeError: Cannot read property ‘length’ of null : Error
at jsStackTrace (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:22715)
at stackTrace (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:22898)
at Object.handleFSError (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:74417)
at _mmap (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:308189)
at Array.Ans (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:32:280899)
at Object.Fjs [as dynCall_iiiiiii] (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:32:254147)
at invoke_iiiiiii (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:338421)
at Sdq (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:31:186156)
at Array.EAq (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:31:430097)
at Object.gms [as dynCall_ii] (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:32:271915)
blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:39 Uncaught TypeError: Cannot read property ‘length’ of null : Error
at jsStackTrace (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:22715)
at stackTrace (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:22898)
at Object.handleFSError (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:74417)
at _mmap (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:308189)
at Array.Ans (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:32:280899)
at Object.Fjs [as dynCall_iiiiiii] (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:32:254147)
at invoke_iiiiiii (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:338421)
at Sdq (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:31:186156)
at Array.EAq (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:31:430097)
at Object.gms [as dynCall_ii] (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:32:271915)callMain @ blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:39doRun @ blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:39(anonymous function) @ blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:39