SetCorsBehavior and CustomRequestHeaders


I have a react app which is retrieving img data from a google cloud storage bucket, but am getting CORS policy issues when trying to access the same bucket from within Babylon. Looking through the request headers, it looks like ‘Sec-Fetch-Mode’ is set to ‘cors’ for Babylon and ‘no-cors’ for the React img request.

In the documentation I have found WebRequest.CustomRequestHeaders and a Tools.SetCorsBehavior function which seem promising, but I have been unable to affect the behavior so far. In the case of CustomRequestHeaders, setting ‘Sec-Fetch-Mode’ to ‘no-cors’ is not allowed, and I have not been able to get SetCorsBehavior to work.

Tools.SetCorsBehavior(fileUrl, { crossOrigin: null });

The code above was based on the only example implementation I could find, and may not be correct.

Let me know if you have any experience with customizing request headers or modifying cors policy on fetches made through SceneLoader (LoadAssetContainerAsync), and thanks,

Hey Robert!
How is the CORS setup on the server? Do you allow all origins and any header?

Hey Roland,

The CORS configuration was on the google storage bucket and I’m not sure why I didn’t think to modify it there… Thanks for pointing out something I should have plainly seen.

For anyone interested, here is an article on how to set it up:


1 Like

I’m glad it helped. Would you please close the question by marking a/the only one :slight_smile: solution please? Thank you!

Please note that CORS is always enforced by the browser and the server not by the client code.