From 53445057184aa731ee7456b33b70bc0ecf82f2a6 Mon Sep 17 00:00:00 2001 From: sahlex <1122279+sahlex@users.noreply.github.com> Date: Thu, 9 Oct 2025 16:07:02 +0200 Subject: [PATCH] fix: run docling ui behind a reverse proxy using a context path (#396) Signed-off-by: Sahler.Alexander Signed-off-by: sahlex <1122279+sahlex@users.noreply.github.com> Co-authored-by: Sahler.Alexander --- docling_serve/app.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docling_serve/app.py b/docling_serve/app.py index 58ebe5b..1a16f38 100644 --- a/docling_serve/app.py +++ b/docling_serve/app.py @@ -194,16 +194,25 @@ def create_app(): # noqa: C901 import gradio as gr from docling_serve.gradio_ui import ui as gradio_ui + from docling_serve.settings import uvicorn_settings tmp_output_dir = get_scratch() / "gradio" tmp_output_dir.mkdir(exist_ok=True, parents=True) gradio_ui.gradio_output_dir = tmp_output_dir + + # Build the root_path for Gradio, accounting for UVICORN_ROOT_PATH + gradio_root_path = ( + f"{uvicorn_settings.root_path}/ui" + if uvicorn_settings.root_path + else "/ui" + ) + app = gr.mount_gradio_app( app, gradio_ui, path="/ui", allowed_paths=["./logo.png", tmp_output_dir], - root_path="/ui", + root_path=gradio_root_path, ) except ImportError: _log.warning(