Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.Close
For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.Close
If you try to access content using WWW, and the remote server does not have CORS set up or configured correctly, you will see and error like this in the browser console:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://myserver.com/. This can be fixed by moving the resource to the same domain or enabling CORS.
CORS stands for Cross-Origin Resource Sharing, and is documented here. Basically, the server needs to add some Access-Control headers to the http responses it sends out, which will tell browsers that it is allowed to let web pages access the content on the server. Here’s an example of a header setup, which would allow Unity WebGL to access resources on a web server from any origin, with common request headers and using the http GET, POST or OPTIONS methods:
"Access-Control-Allow-Credentials": "true", "Access-Control-Allow-Headers": "Accept, X-Access-Token, X-Application-Name, X-Request-Sent-Time", "Access-Control-Allow-Methods": "GET, POST, OPTIONS", "Access-Control-Allow-Origin": "*",
Note that WWW.responseHeaders is limited to a subset of the actual response headers, according to 7.1.1 of the CORS specification.
Also note that XMLHttpRequest does not allow streaming of data, thus the WWW class on WebGL will only process any data once the download has finished (so AssestBundles cannot be decompressed and loaded while downloading as on other platforms).