Skip to content

Commit deda754

Browse files
committed
Send X-XSRFToken header
1 parent 2ea00a6 commit deda754

File tree

1 file changed

+3
-0
lines changed
  • share/jupyter/voila/templates/default/static

1 file changed

+3
-0
lines changed

share/jupyter/voila/templates/default/static/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ require(['static/voila'], function(voila) {
3939

4040
async function init() {
4141
// it seems if we attach this to early, it will not be called
42+
const matches = document.cookie.match('\\b_xsrf=([^;]*)\\b');
43+
const xsrfToken = (matches && matches[1]) || '';
4244
window.addEventListener('beforeunload', function (e) {
4345
const xhttp = new XMLHttpRequest();
4446
xhttp.open("DELETE", `/api/kernels/${kernel.id}`, false);
47+
xhttp.setRequestHeader('X-XSRFToken', xsrfToken);
4548
xhttp.send();
4649
kernel.dispose();
4750
});

0 commit comments

Comments
 (0)