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

AngularJS X-XSRF-TOKEN Request Header

2 Answers 24 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 17 Feb 2021, 09:51 PM

Is the code below still the only way to set the required AngularJS XSRF token when uploading or removing files? The value of the token needs to be taken from the XSRF-TOKEN cookie.

 

function onUpload(e) {

var xhr = e.XMLHttpRequest;

if (xhr) { xhr.addEventListener("readystatechange", function (e)

    {if (xhr.readyState == 1 /* OPENED */) {

         xhr.setRequestHeader("X-Foo", "Bar");

    }})}}

 

2 Answers, 1 is accepted

Sort by
0
Jason
Top achievements
Rank 1
answered on 18 Feb 2021, 11:30 AM

Clarifications:

1. Is there a way to do this globally so that the same boilerplate code does not have to be added to each upload definition?

2. Is e.headers exposed for the upload event as it is supposed to be for the remove event?

0
Petar
Telerik team
answered on 19 Feb 2021, 12:02 PM

Hi Jason,

Here are the answers to your questions:

  1. The headers should be set for each Upload component separately
  2. The e.headers property is not exposed for the upload event. If you think that it should be available in the upload event, please submit a feature request in our feedback portal. Based on the interest the item collects, we may consider the implementation of the header property in the upload event. 

Regards,
Petar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Upload
Asked by
Jason
Top achievements
Rank 1
Answers by
Jason
Top achievements
Rank 1
Petar
Telerik team
Share this question
or