JC-comp commented on code in PR #63141:
URL: https://github.com/apache/airflow/pull/63141#discussion_r2910120720


##########
airflow-core/src/airflow/ui/src/pages/Security.tsx:
##########
@@ -43,8 +43,18 @@ 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 baseHref = document.querySelector("base")?.href;
+      const basename = baseHref === undefined ? "" : new 
URL(baseHref).pathname.replace(/\/$/u, "");

Review Comment:
   Since we're already within a routing context, we can avoid manual DOM 
scraping of the `<base>` tag. Using 
[`useHref`](https://reactrouter.com/api/hooks/useHref) to resolve `/auth` 
automatically respects the `basename` configured in the Router provider. This 
makes the logic cleaner and removes the need to manually slice or parse the 
`iframePath`.
   ```js
   const authPath = useHref("/auth");
   ...
   const onLoad = () => {
     if (!iframePath.startsWith(authPath)) {
     ...
     }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to