Skip to content

Conversation

@KoMinkyu
Copy link

@KoMinkyu KoMinkyu commented Jan 1, 2026

Summary

Improves upon #6587 by fixing a bug where MIME type detection fails for URLs with query parameters or hash fragments.

Problem

The current implementation (from #6587) uses path.endsWith(ext) which fails for:

  • /assets/file.js?v=123 - common for cache busting
  • /assets/file.js#source-map - used in source maps
    This causes these files to be served without Content-Type headers, breaking module loading.

Changes

  • Extract pathname without query params/hash before extension checking
  • Add charset=utf-8 to text-based MIME types (JS, CSS, JSON) for standards compliance

- Extract pathname without query params/hash before checking extensions
- Add charset=utf-8 for text-based MIME types (js, mjs, css, json)
- Maintain original behavior: always set Content-Type for static assets
- Remove .html from mimeTypes to avoid overriding Cloudflare's correct type

Fixes issue where module scripts failed to load with empty MIME type
when paths contained query parameters (e.g., /file.js?v=123)
@KoMinkyu KoMinkyu closed this Jan 1, 2026
@KoMinkyu
Copy link
Author

KoMinkyu commented Jan 1, 2026

Closing as #6587 is sufficient for the current production build setup.

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