diff --git a/airflow-core/newsfragments/63141.bugfix.rst b/airflow-core/newsfragments/63141.bugfix.rst new file mode 100644 index 0000000000000..c9855b3f5e49b --- /dev/null +++ b/airflow-core/newsfragments/63141.bugfix.rst @@ -0,0 +1 @@ +Fix security iframe navigation when AIRFLOW__API__BASE_URL basename is configured diff --git a/airflow-core/src/airflow/ui/src/pages/Security.tsx b/airflow-core/src/airflow/ui/src/pages/Security.tsx index 011c101868697..c3b0fb89309d4 100644 --- a/airflow-core/src/airflow/ui/src/pages/Security.tsx +++ b/airflow-core/src/airflow/ui/src/pages/Security.tsx @@ -17,8 +17,7 @@ * under the License. */ import { Box } from "@chakra-ui/react"; -import { useParams } from "react-router-dom"; -import { useNavigate } from "react-router-dom"; +import { useNavigate, useParams } from "react-router-dom"; import { useAuthLinksServiceGetAuthMenus } from "openapi/queries"; import { ProgressBar } from "src/components/ui"; @@ -43,8 +42,12 @@ export const Security = () => { const onLoad = () => { const iframe: HTMLIFrameElement | null = document.querySelector("#security-iframe"); - if (iframe?.contentWindow && !iframe.contentWindow.location.pathname.startsWith("/auth/")) { - void Promise.resolve(navigate("/")); + if (iframe?.contentWindow) { + const base = new URL(document.baseURI).pathname.replace(/\/$/u, ""); // Remove trailing slash if exists + + if (!iframe.contentWindow.location.pathname.startsWith(`${base}/auth/`)) { + void navigate("/"); + } } };