-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
jupyterlab/jupyter-collaboration
#501Labels
Description
Description
When c.JupyterHub.subdomain_host is set, the hubHost variable passed to the frontend (JupyterLab/Notebook) includes the scheme as well (https://myhub.example.org). However, the frontend expects hubHost to be just the hostname (and optional port), without the scheme.
This can cause issues for frontend logic that constructs URLs or interacts with browser APIs requiring just the host.
To Reproduce
- Set
subdomain_hostin JupyterHub config:c.JupyterHub.subdomain_host = "https://myhub.example.org"
- Start JupyterHub and launch a single-user server.
- Inspect the
page_configin the frontend (window.jupyterhuborwindow.page_config_data). Alternatively confirm thatJUPYTERHUB_HOSTenv var contains the URL scheme. - Observe that
hubHostis:instead of the expected:"hubHost": "https://myhub.example.org""hubHost": "myhub.example.org"
Expected behavior
hubHostshould contain just the hostname (and optional port), e.g.,myhub.example.org, not includehttps://.
Actual behavior
hubHostcontains the scheme, e.g.,https://myhub.example.org.
Impact
- Frontend code that expects a host (not a full URL) may malfunction, causing URL construction errors, cookie issues, or broken redirects.
Proposed solution
-
When constructing
hubHostfor the frontend, strip the scheme and pass only the netloc/hostname part.from urllib.parse import urlparse parsed = urlparse(self.hub_auth.hub_host) page_config["hubHost"] = parsed.netloc or self.hub_auth.hub_host
Environment
- JupyterHub version: 5.3.0
- JupyterLab or Notebook version: 4.4.6
Additional context
- This issue can lead to subtle frontend bugs that are hard to track down. I found it by backtracking a bug in jupyterlab-collaboration.