This is an automated email from the ASF dual-hosted git repository.

ash pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 4805257608f Cope with more "interesting" proxy configurations when 
accessing the UI (#49118)
4805257608f is described below

commit 4805257608f84812f6e56ee2e6c8d639ec8375aa
Author: Ash Berlin-Taylor <[email protected]>
AuthorDate: Fri Apr 11 12:38:59 2025 +0100

    Cope with more "interesting" proxy configurations when accessing the UI 
(#49118)
    
    A follow up to #49106, we don't actually need to specify the host, and in 
some
    more complex routing circumstances with WAFs and multiple layers of (not
    prefectly configured) proxies etc this can lead to a different hostname
    between what the UA sent and what makes it to the Airflwo API server.
    
    However we can simplify this, and just use the `path` property -- this will
    always be right (defaults to a sane value, but uses the correct value from 
the
    base URL config option.)
---
 .../airflow/api_fastapi/auth/managers/simple/simple_auth_manager.py    | 3 +--
 airflow-core/src/airflow/api_fastapi/core_api/app.py                   | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git 
a/airflow-core/src/airflow/api_fastapi/auth/managers/simple/simple_auth_manager.py
 
b/airflow-core/src/airflow/api_fastapi/auth/managers/simple/simple_auth_manager.py
index 2746fbadecd..b3ce04a94b8 100644
--- 
a/airflow-core/src/airflow/api_fastapi/auth/managers/simple/simple_auth_manager.py
+++ 
b/airflow-core/src/airflow/api_fastapi/auth/managers/simple/simple_auth_manager.py
@@ -306,10 +306,9 @@ class 
SimpleAuthManager(BaseAuthManager[SimpleAuthManagerUser]):
 
         @app.get("/{rest_of_path:path}", response_class=HTMLResponse, 
include_in_schema=False)
         def webapp(request: Request, rest_of_path: str):
-            schema_relative_base = 
str(request.base_url).removeprefix(request.base_url.scheme + ":")
             return templates.TemplateResponse(
                 "/index.html",
-                {"request": request, "backend_server_base_url": 
schema_relative_base},
+                {"request": request, "backend_server_base_url": 
request.base_url.path},
                 media_type="text/html",
             )
 
diff --git a/airflow-core/src/airflow/api_fastapi/core_api/app.py 
b/airflow-core/src/airflow/api_fastapi/core_api/app.py
index f0984fa8567..659e80d5f38 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/app.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/app.py
@@ -66,10 +66,9 @@ def init_views(app: FastAPI) -> None:
 
     @app.get("/{rest_of_path:path}", response_class=HTMLResponse, 
include_in_schema=False)
     def webapp(request: Request, rest_of_path: str):
-        schema_relative_base = 
str(request.base_url).removeprefix(request.base_url.scheme + ":")
         return templates.TemplateResponse(
             "/index.html",
-            {"request": request, "backend_server_base_url": 
schema_relative_base},
+            {"request": request, "backend_server_base_url": 
request.base_url.path},
             media_type="text/html",
         )
 

Reply via email to