Hi all,
I have a project that makes WWW and UnityWebRequest.GetAssetBundle requests to an Apache server.
When I run it from Unity IDE (clicks the “play” button) it works great. However, when I build it and run as WebGL it doesn’t work.
When looking at the browser’s console I see the following error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://local.store3d.com/AssetBundles/global/fixtures. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
I thought that the error had to do with AssetBundles but I got a similar error when trying to load a simple JSON file:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://local.store3d.com/data_website_1.json. (Reason: missing token ‘access-control-allow-credentials’ in CORS header ‘Access-Control-Allow-Headers’ from CORS preflight channel).
After searching the issue I applied CORS to my Apache using .htaccess file and directly into the VirtualHost file and tried a few other “tricks” that I found on the web but nothing works.
I tested the URLs (http://local.store3d.com/data_website_1.json and http://local.store3d.com/AssetBundles/global/fixtures) directly in my browser and could see the pages. I tested the same URLs in “Postman” and I could see the response and that there is a header
“access-control-allow-origin →*”
It seems that the only place where it doesn’t work is WebGL…
What might cause this? More importantly, how can I solve this issue???
Any help will be highly appreciated!!!
Thanks!