Skip to content

Proxy blindly prepends base path to HTTP redirects, causing double-path 404s #574

@StickyDoughnut

Description

@StickyDoughnut

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

  1. Start a JupyterLab environment (e.g., inside Kubeflow).
  2. Install jupyter-server-proxy==4.5.0 and label-studio in a virtual environment.
  3. 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/"
  4. Start the application in the terminal:
    label-studio start --port 8080
  5. Open a browser and navigate to the base URL:
    https://<jupyter-domain>/notebook/<namespace>/<notebook-name>/proxy/8080/
  6. 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/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions