This is a migrated thread and some comments may be shown as answers.

withCredentials cannot be set to false

1 Answer 251 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 24 Jun 2014, 11:58 PM
Hello,

When uploading files, we have the need to set the withCredentials to false on the XmlHttpRequest. My upload event implementation is as follows:

upload: function (e) {
    var xhr = e.XMLHttpRequest;
    if (xhr) {
        xhr.addEventListener('readystatechange', function (event) {
            if (xhr.readyState == 1) {
                    xhr.withCredentials = false;
                    xhr.setRequestHeader("Authorization", "Bearer " + token);
                    xhr.crossDomain = true;
            }
        });
    }
}

The problem is that the code inside of kendo.all.js for postFormData() overrides the withCredentials value with a "true" after the xhr open event is fired. Thus overriding any setting to the string value of "true", prior to sending.

The code in kendo.all.js is as follows:

xhr.open("POST", url, true);
xhr.withCredentials = "true";
xhr.send(data);

A fix for the issue would be to set the withCredentials value prior to opening the xhr as follows:

xhr.withCredentials = true;
xhr.open("POST", url, true);
 
xhr.send(data);

Please let me know if I am doing something wrong, or if there any plans to change this.

1 Answer, 1 is accepted

Sort by
0
Accepted
Vladimir Iliev
Telerik team
answered on 27 Jun 2014, 06:32 AM
Hi Daniel,

Please note that this option is already configurable from the KendoUI Q2 Beta release (official release is expected in mid July) - please check the change log below:

Upload

NEW
  • Add withCredentials setting for async uploads. Default is true.

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Upload
Asked by
Daniel
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or