Skip to content

fix(web): serve JavaScript assets with module-safe MIME type - #2100

Open
Sisyphbaous-DT-Project wants to merge 2 commits into
MoonshotAI:mainfrom
Sisyphbaous-DT-Project:fix/web-static-js-mime
Open

fix(web): serve JavaScript assets with module-safe MIME type#2100
Sisyphbaous-DT-Project wants to merge 2 commits into
MoonshotAI:mainfrom
Sisyphbaous-DT-Project:fix/web-static-js-mime

Conversation

@Sisyphbaous-DT-Project

@Sisyphbaous-DT-Project Sisyphbaous-DT-Project commented Apr 28, 2026

Copy link
Copy Markdown

Related Issue

Resolve #2074

Description

This PR fixes a Web UI startup failure on Windows where JavaScript assets can be served with text/plain instead of a browser-safe JavaScript MIME type.

On some Windows environments, Python's MIME type detection can resolve .js files to text/plain. Since the Web UI loads Vite-built assets as module scripts, browsers reject those responses with strict MIME checking before the page can finish loading.

The fix is intentionally scoped to the /web static file path:

  • add a small StaticFiles subclass for the Kimi Web UI
  • preserve the existing Starlette static-file behavior
  • override Content-Type only for served .js assets
  • avoid changing CLI startup, auth/CORS, session worker logic, frontend build output, or global MIME mappings

A regression test simulates the problematic .js -> text/plain MIME mapping and verifies that the served asset still receives a module-safe JavaScript MIME type.

Tests

  • python -m pytest tests/web/test_static_mime.py -vv
  • python -m pytest tests/web -vv

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked the related issue, if any.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have run make gen-changelog to update the changelog. (N/A — targeted Web UI MIME bugfix)
  • I have run make gen-docs to update the user documentation. (N/A — no user-facing documentation changes)

Open in Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

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

Labels

None yet

Projects

None yet

1 participant