Repository navigation
Conversation
Python's mimetypes reads the Windows registry, where .js is often mapped to text/plain. Starlette then serves the Vite bundle with the wrong Content-Type, browsers refuse to run the module script, and the UI is a blank page. Register explicit mappings at server import so they win over the registry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🔍 QA report: ✅ PassedTester: Barbara (cubefarm agent, in a fresh session) · Round: 1 · Author: Dennis The PR sets the MIME types for .js, .mjs, .css, .svg, .json and .wasm in server/main.py when the server starts, overriding whatever the Windows registry says. With a simulated bad registry, master already served .js correctly (settings.py forces it) but sent CSS and SVG as text/plain. With the PR every UI file has the right Content-Type and the app renders with no console errors. Lint, build and the new tests pass; the only failing tests also fail on master. Tested on Linux with a fake registry, not on real Windows.
🧪 Commands run
No browser screenshots were taken in this round. Posted by cubefarm · merges automatically once GitHub's checks pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #49
Problem
On some Windows machines the UI loads as a blank page with
Failed to load module script ... MIME type of "text/plain". Python'smimetypesmodule seeds itself from the Windows registry (HKEY_CLASSES_ROOT\.js\Content Type), which editors/tools often set totext/plain. Starlette'sStaticFiles/FileResponseusemimetypes.guess_type, so the Vite bundle gets served astext/plainand the browser rejects it.Fix
server/main.pynow callsmimetypes.add_type(...)at import time for.js,.mjs,.css,.svg,.json,.wasm.add_typeinitializes the database (including the registry) first and then overrides, so these mappings always win regardless of registry contents.Verification
test_static_mime.py: simulates a poisoned registry (.js/.css→text/plain), importsserver.main, and checks bothguess_typeand an actualStaticFilesresponseContent-Type. Fails on master (2 failed), passes with this change (2 passed).ruff check .clean;python test_security.pypasses.Assumptions
text/javascript(current WHATWG / RFC 9239 recommendation) rather thanapplication/javascript; browsers accept either.🤖 Generated with Claude Code