Skip to content

fix(windows): restore MIME correction for multi-dist frontend assets - #296

Open
lottshin wants to merge 1 commit into
OpenBMB:mainfrom
lottshin:fix/windows-frontend-mime
Open

lottshin wants to merge 1 commit into
OpenBMB:mainfrom
lottshin:fix/windows-frontend-mime

Conversation

@lottshin

Copy link
Copy Markdown

On Windows machines where the system MIME database maps .js to text/plain, browsers reject the frontend module and the page stays blank. The multi-dist asset handler inherited directly from StaticFiles, bypassing the existing MIME correction in FrontendStaticFiles.

Make MultiDistStaticFiles inherit from FrontendStaticFiles to restore that correction while preserving its directory lookup and path checks. Update the regression test to exercise the registered handlers for /assets, /enterprise/assets, /chat/assets, /workspace/assets, and /admin/assets, using GET and HEAD with an asset present only in the fallback build directory.

Validation:

  • PYTHONPATH=backend:backend/src DATABASE_URL=sqlite:///:memory: ULTRARAG_DATA_DIR=<temporary-directory> python -m pytest backend/tests/test_single_port_app.py -q: 20 passed, with real application imports and no application stubs.
  • Temporarily removing only the inheritance fix makes all 10 regression cases fail with text/plain.
  • git diff --check passes. Ruff reports the same seven pre-existing I001/RUF100 diagnostics before and after this change.
  • Tested on macOS with Python 3.11.15, FastAPI 0.143.1, and Starlette 0.46.2. Windows MIME behavior is simulated by injecting the broken MIME mapping. No native Windows or browser UI validation was performed; the tested static asset requests are unauthenticated.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant