Skip to content

Commit bece2c4

Browse files
authored
Merge pull request #38272 from mitodl/asad/pick-csrf-from-cookie
fix: read latest CSRF token from cookie
2 parents 7bcf9f8 + 86ef4cd commit bece2c4

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lms/static/js/main.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
$(function() {
99
$.ajaxSetup({
10-
headers: {
11-
'X-CSRFToken': $.cookie('csrftoken')
10+
beforeSend: function(xhr, settings) {
11+
if (!(/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type)) && !this.crossDomain) {
12+
xhr.setRequestHeader('X-CSRFToken', $.cookie('csrftoken'));
13+
}
1214
},
1315
dataType: 'json'
1416
});

0 commit comments

Comments
 (0)