From c42f08a0832a9abdd131be246d339df2c2ce00f3 Mon Sep 17 00:00:00 2001 From: yamato matsuoka Date: Fri, 17 Nov 2023 05:57:29 -0500 Subject: [PATCH] Resolve 'Show Logs' issue by adding _xsrf token in JupyterHub 4 (#61) Co-authored-by: Jeremy Tuloup --- 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);