Bug description
In version 4.5.0, jupyter-server-proxy aggressively rewrites HTTP 302 Location headers returned by a proxied application, even if the application already included the proxy path in its absolute redirect URL.
This results in a duplicated path and a 404 error. This breaks applications like Label Studio, which require their external base URL to be explicitly defined via environment variables so that static assets load correctly.
This is a regression. In version 4.4.0, this exact setup works perfectly without duplicating the redirect path.
How to reproduce
- Start a JupyterLab environment (e.g., inside Kubeflow).
- Install
jupyter-server-proxy==4.5.0 and label-studio in a virtual environment.
- Export the application's required host URL using the proxy's absolute path:
export LABEL_STUDIO_HOST="https://<jupyter-domain>/notebook/<namespace>/<notebook-name>/proxy/8080/"
- Start the application in the terminal:
label-studio start --port 8080
- Open a browser and navigate to the base URL:
https://<jupyter-domain>/notebook/<namespace>/<notebook-name>/proxy/8080/
- The application receives the unauthenticated request and generates an HTTP 302 redirect to its login page:
Location: https://<jupyter-domain>/notebook/<namespace>/<notebook-name>/proxy/8080/user/login/
Expected behaviour
The proxy should recognize that the Location header is already an absolute URL pointing to the correct proxy path (or correctly handle the app's X-Forwarded-Host headers). The user should land cleanly on:
https://<jupyter-domain>/notebook/<namespace>/<notebook-name>/proxy/8080/user/login/
Actual behaviour
The proxy intercepts the redirect and blindly prepends its routing prefix to the URL again, sending the user to a duplicated 404 path:
https://<jupyter-domain>/notebook/<namespace>/<notebook-name>/proxy/8080/notebook/<namespace>/<notebook-name>/proxy/8080/user/login/
Bug description
In version
4.5.0,jupyter-server-proxyaggressively rewrites HTTP 302Locationheaders returned by a proxied application, even if the application already included the proxy path in its absolute redirect URL.This results in a duplicated path and a 404 error. This breaks applications like Label Studio, which require their external base URL to be explicitly defined via environment variables so that static assets load correctly.
This is a regression. In version
4.4.0, this exact setup works perfectly without duplicating the redirect path.How to reproduce
jupyter-server-proxy==4.5.0andlabel-studioin a virtual environment.export LABEL_STUDIO_HOST="https://<jupyter-domain>/notebook/<namespace>/<notebook-name>/proxy/8080/"label-studio start --port 8080https://<jupyter-domain>/notebook/<namespace>/<notebook-name>/proxy/8080/Location: https://<jupyter-domain>/notebook/<namespace>/<notebook-name>/proxy/8080/user/login/Expected behaviour
The proxy should recognize that the
Locationheader is already an absolute URL pointing to the correct proxy path (or correctly handle the app'sX-Forwarded-Hostheaders). The user should land cleanly on:https://<jupyter-domain>/notebook/<namespace>/<notebook-name>/proxy/8080/user/login/Actual behaviour
The proxy intercepts the redirect and blindly prepends its routing prefix to the URL again, sending the user to a duplicated 404 path:
https://<jupyter-domain>/notebook/<namespace>/<notebook-name>/proxy/8080/notebook/<namespace>/<notebook-name>/proxy/8080/user/login/