From f3eaceb67ecb79f0c9641c951ec7439852f8446a Mon Sep 17 00:00:00 2001 From: Yamato Matsuoka Date: Wed, 8 Nov 2023 20:27:31 -0500 Subject: [PATCH] Resolve 'Show Logs' issue by adding _xsrf token in JupyterHub 4 --- tljh_repo2docker/static/js/images.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tljh_repo2docker/static/js/images.js b/tljh_repo2docker/static/js/images.js index 9d0aeb0..ee186db 100644 --- a/tljh_repo2docker/static/js/images.js +++ b/tljh_repo2docker/static/js/images.js @@ -128,6 +128,11 @@ require([ fitAddon.fit(); var logsUrl = utils.url_path_join(base_url, "api", "environments", image, "logs"); + if (api.xsrf_token) { + // add xsrf token to url parameter + var sep = logsUrl.indexOf("?") === -1 ? "?" : "&"; + logsUrl = logsUrl + sep + "_xsrf=" + api.xsrf_token; + } eventSource = new EventSource(logsUrl); eventSource.onerror = function(err) { console.error("Failed to construct event stream", err);