fix: normalize JS static MIME types on Windows

Refs #802
This commit is contained in:
Kevin
2026-06-02 01:30:38 +02:00
parent 7b9ef95b60
commit 1494a0b7ee
2 changed files with 54 additions and 0 deletions

17
app.py
View File

@@ -1,6 +1,23 @@
# app.py — slim orchestrator
import mimetypes
import os
def register_static_mime_types() -> None:
"""Force stable JS module MIME types across platforms.
Some native Windows setups inherit stale/incorrect registry mappings for
``.js``/``.mjs``, which can make Starlette serve ES modules with a non-JS
``Content-Type`` and cause the UI to load but fail on click. Re-register the
standard MIME types at startup so static assets are served consistently.
"""
mimetypes.add_type("text/javascript", ".js")
mimetypes.add_type("application/javascript", ".mjs")
register_static_mime_types()
# Windows: force HuggingFace/fastembed to COPY model files instead of symlinking.
# On a network-share/UNC data dir Windows can't follow HF's symlinks ([WinError
# 1463]), so the ONNX embedding model fails to load. huggingface_hub reads this