Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion share/jupyter/voila/templates/base/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ require([window.voila_js_url || 'static/voila'], function(voila) {

async function init() {
// it seems if we attach this to early, it will not be called
const matches = document.cookie.match('\\b_xsrf=([^;]*)\\b');
const xsrfToken = (matches && matches[1]) || '';
window.addEventListener('beforeunload', function (e) {
kernel.shutdown();
const xhttp = new XMLHttpRequest();
xhttp.open("DELETE", `/api/kernels/${kernel.id}`, false);
xhttp.setRequestHeader('X-XSRFToken', xsrfToken);
xhttp.send();
kernel.dispose();
});
await widgetManager.build_widgets();
Expand Down