- Home /
CORS request blocked due to x-unity-version header.
We are in the process of updating our Unity project to use the new UnityWebRequest instead of WWW. However in the WebGL build we are encountering CORS errors with a number of third-party services.
For example:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at [url]. (Reason: missing token 'x-unity-version' in CORS header 'Access-Control-Allow-Headers' from CORS preflight channel).
As the error details, this problem is caused by the 'x-unity-version' header that is automatically added by the UnityWebRequest.
According to the UnityWebRequest.SetRequestHeader documentation:
The user-agent and x-unity-version headers are automatically set by Unity and may not be set to custom values.
As these are third-party services, we are unable to configure the Access-Control-Allow-Headers to allow this header. It's critical to our product that we are able to access these third-party services as well as have complete access to the RESTful services that UnityWebRequest provides.
Any advice or assistance would be greatly appreciated.
This is still a problem which is actually quite critical.
Curious, which 3rd party service is rejecting the request due to an X-Unity-Version
header?
Well im working with Firebase and Webgl, trying to download images from a storage bucket.