# CORS Problem when set image.source = url

**URL:** <https://forum.babylonjs.com/t/cors-problem-when-set-image-source-url/35804>\
**Category:** Questions\
**Created:** [November 18, 2022, 8:56am UTC](https://forum.babylonjs.com/t/cors-problem-when-set-image-source-url/35804 "2022-11-18T08:56:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Digital\_Mimesis\_Lab](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/digital_mimesis_lab/32/26710_2.png) [@Digital\_Mimesis\_Lab](https://forum.babylonjs.com/u/Digital_Mimesis_Lab)\
**Post date:** [November 18, 2022, 8:56am UTC](https://forum.babylonjs.com/t/cors-problem-when-set-image-source-url/35804/1 "2022-11-18T08:56:07Z")

</div>

I set the image.source to some asset url held by a server, it returns CORS problem. I know what is CORS, my question is that without change the server’s CORS settings, can I set a JWT along with Babylonjs to solve the CORS problem? Or can I download the image firstly then assign it to image?

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [November 18, 2022, 11:14am UTC](https://forum.babylonjs.com/t/cors-problem-when-set-image-source-url/35804/2 "2022-11-18T11:14:48Z")

</div>

You can do anything the server allows you to do. If the server requires some header manipulation in order for it to work, you can add the header to every web request using this Map: [WebRequest | Babylon.js Documentation](https://doc.babylonjs.com/typedoc/classes/BABYLON.WebRequest#CustomRequestHeaders) . It is a static map and will be applied to every request made!  
Another way (more robust, but of course a little more complicated to implement) is using the request modifiers: [WebRequest | Babylon.js Documentation](https://doc.babylonjs.com/typedoc/classes/BABYLON.WebRequest#CustomRequestHeaders)  
This is an array of callbacks, that get the request object and the url that is being requested, and allow you to manipulate the XMLHttpRequest object according to your needs, based on the URL. so you could add a function doing (in pseudo code!)

```javascript
if(this-is-an-image(url))
  add-jwt-to-request(request)

```

and you are good to go.
