How to send httpOnly cookie, while importing glb meshes?

Suppose the endpoint, that returns glb model, is secured by JWT with httpOnly cookie. The client side uses AssetsManager and .addMeshTask(“task1”, “meshes”, url, “modelName”), but the request doesn’t send cookie for some reason. I tried to get glb model as blob firstly and create url (via createObjectURL),
then pass it to the method above, but got “Unable to find a plugin to load a7915567-6904-4a73-8938-8413d5a6f1f1 files.” error, I checked blob.text, so it’s correct. I don’t know, how Babylon.js uses requests and I have no idea, how to do this. So what are the options? Can I just send cookie somehow? Or can I get a file and just load it to Babylon.js without url?

cc @RaananW as he is amazing with those kind of issues :slight_smile:

1 Like

You can do whatever you want to do :slight_smile:

Babylon has a wonderful mechanism of augmenting your web requests, so you can send auth data or cookies. You have the ability to change the request altogether, or just add headers to the request (just what you need, as you want to send a cookie - Set-Cookie - HTTP | MDN)

I assume you have access to the cookie data? If you don’t it needs to be set for a specific domain in your browser and then it will be sent automatically when interacting with this server.

To augment the headers of your web request use this:

To make changed to the XMLHttpRequest directly, use this:

1 Like

Thank you very much!!! I added the following code and now it works: :smile:

WebRequest.CustomRequestModifiers = [
    request => request.withCredentials = true

Trying to keep everything as simple as possible! So glad it was just that :slight_smile:

1 Like