fix: return 404 for missing assets instead of index.html fallback

Prevents MIME type mismatch when asset filenames change after rebuild.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-26 18:46:35 +00:00
parent 22b05617d4
commit 814e5a182c
+3
View File
@@ -551,6 +551,9 @@ class APIHandler(BaseHTTPRequestHandler):
path = '/index.html'
file_path = os.path.join(DIST_DIR, path.lstrip('/'))
if not os.path.isfile(file_path):
# Only fallback to index.html for routes, not for asset files
if path.startswith('/assets/') or '.' in path.split('/')[-1]:
self._respond(404, {'error': 'Not found'}); return
file_path = os.path.join(DIST_DIR, 'index.html')
try:
with open(file_path, 'rb') as f: