edsu opened a new pull request, #72374:
URL: https://github.com/apache/airflow/pull/72374

   When Airflow is served under a path prefix, the UI sent its first API 
request to the origin root instead of the prefix.
   
   `OpenAPI.BASE` was assigned as a module side effect in `queryClient.ts`, 
which imports `src/i18n/config`. That module requests the version at module 
scope to build a translation cache buster, and ES module evaluation runs a 
dependency to completion before the importing module's body, so the request 
always went out while `BASE` was still `""`. The generated client builds its 
URL as `config.BASE + path`, so the request was sent to the origin root.
   
   The consequences depend on what else is mounted at `/api/`. In our case the 
request reaches a different service API, that responded with a 401, which the 
UI reads as an expired session, which redirects to login, which succeeds and 
reloads, producing an infinite login loop. The request also defeats the feature 
it exists for: the lookup fails, `resolveI18nVersion` falls back to 
`Date.now()`, and translations are fetched with a timestamp instead of the 
version.
   
   Move the base href resolution and the client configuration into 
`src/basePath`, a module with no application dependencies, and have 
`i18n/config` take its base path from there. The ordering guarantee then comes 
from a real data dependency rather than from the import graph happening to line 
up.
   
   `utils/links.ts` still reads `<base href>` separately, but it does so at 
call time rather than module scope, so it is unaffected; consolidating it is 
left out to keep this change to the bug.
   
   Adds a regression test that fails on main with
   `expected [ '/api/v2/version' ] to deeply equal []`.
   
   Closes: #72344
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: [Claude Code (Opus 5)] following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   


-- 
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