Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ function status(text) {
// This page is served under the /desktop/, and the websockify websocket is served
// under /desktop-websockify/ with the same base url as /desktop/. We resolve it relatively
// this way.
let websockifyUrl = new URL("../desktop-websockify/", window.location);
let websockifyUrl = new URL(
window.location.pathname.replace(/\/+$/, "") + "-websockify/",
window.location,
);
websockifyUrl.protocol = window.location.protocol === "https:" ? "wss" : "ws";

let retryCount = 0;
Expand Down
37 changes: 22 additions & 15 deletions jupyter_remote_desktop_proxy/server_extension.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from pathlib import Path

from jupyter_server.base.handlers import AuthenticatedFileHandler
Expand All @@ -15,18 +16,24 @@ def load_jupyter_server_extension(server_app):
"""
base_url = server_app.web_app.settings["base_url"]

server_app.web_app.add_handlers(
".*",
[
# Serve our own static files
(
url_path_join(base_url, "/desktop/static/(.*)"),
AuthenticatedFileHandler,
{"path": (str(HERE / "static"))},
),
# To simplify URL mapping, we make sure that /desktop/ always
# has a trailing slash
(url_path_join(base_url, "/desktop"), AddSlashHandler),
(url_path_join(base_url, "/desktop/"), DesktopHandler),
],
)
endpoints = ['desktop']
jupyter_remote_desktop_endpoints = os.getenv('JUPYTER_REMOTE_DESKTOP_ENDPOINTS', '')
if jupyter_remote_desktop_endpoints:
endpoints.extend(jupyter_remote_desktop_endpoints.split(','))

for endpoint in endpoints:
server_app.web_app.add_handlers(
".*",
[
# Serve our own static files
(
url_path_join(base_url, f"/{endpoint}/static/(.*)"),
AuthenticatedFileHandler,
{"path": (str(HERE / "static"))},
),
# To simplify URL mapping, we make sure that /desktop/ always
# has a trailing slash
(url_path_join(base_url, f"/{endpoint}"), AddSlashHandler),
(url_path_join(base_url, f"/{endpoint}/"), DesktopHandler),
],
)