Fix tile URL prefix for JupyterHub deployments#39
Open
gcaer wants to merge 1 commit into
Open
Conversation
Collaborator
|
Thanks @GwenaelCaer, but I think the work is now happening in https://github.com/geojupyter/jupyter-tiler. |
Author
|
Thanks @davidbrochart , I didn't know this repository existed, I'll have a look at it then ;) |
Member
Correct! jupyter-tiler is intended to be used with any mapping tool, but it's based on jupytergis-tiler. I'm certain it has the same problem! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: This diagnosis and fix come from Claude Code. It makes sense to me, but I'm not deep enough in the JupyterGIS internals to be 100% confident. Feel free to close this if it's off-base.
Problem
When
jupytergis-tileris used inside JupyterHub, tile layers added viaadd_tiler_layer()are not rendered on the map.In JupyterHub, each user's Jupyter server is served under a URL prefix such as
/user/username/. TheJupyterGISHandleris therefore registered at/user/username/jupytergis_tiler/(.*). However, tile URLs were hardcoded to/jupytergis_tiler/...without this prefix, so browser requests never reached the handler — JupyterHub had no route to forward them to the user's server.The issue does not occur in standalone JupyterLab, where
base_urlis/.Fix
gis_document.pyRead the
JUPYTERHUB_SERVICE_PREFIXenvironment variable (set by JupyterHub for all single-user servers) to prepend the correct base URL when constructing tile URLs:When
JUPYTERHUB_SERVICE_PREFIXis not set (standalone JupyterLab), behaviour is unchanged.handler.pyThe proxy handler now forwards the HTTP status code and the
Content-Typeheader from the upstream tile server response.Without this fix, errors from the tile server were silently swallowed (always returning HTTP 200), and stricter environments such as JupyterHub (which may set
X-Content-Type-Options: nosniff) could refuse to render tiles without an explicitContent-Type: image/png.Testing
JUPYTERHUB_SERVICE_PREFIXset)