Skip to content

docs: clarify MIME type changes when migrating from Express 4 to 5#1903

Merged
ShubhamOulkar merged 8 commits intoexpressjs:gh-pagesfrom
achaljhawar:gh-pages
Jun 23, 2025
Merged

docs: clarify MIME type changes when migrating from Express 4 to 5#1903
ShubhamOulkar merged 8 commits intoexpressjs:gh-pagesfrom
achaljhawar:gh-pages

Conversation

@achaljhawar
Copy link
Copy Markdown
Contributor

This PR improves the Express 5 migration guide by documenting an important change in MIME type handling that affects users migrating from Express 4 to Express 5.

Issue #1880

When migrating from Express 4 to Express 5, we discovered that JavaScript files served via res.sendFile() now return a Content-Type of "text/javascript" instead of the previous "application/javascript". This change occurs because Express 5 switched from its internal MIME type handling to the mime-types package.

Changes

  • Added explanatory notes to the express.static.mime section explaining that this change affects other methods like res.sendFile()
  • Added a specific note to the res.sendfile() section warning about potential Content-Type differences
  • Provided concrete examples of the JavaScript MIME type change to help users anticipate similar issues

These documentation improvements will help users understand and prepare for potential MIME type differences when upgrading to Express 5, even if they weren't directly using express.static.mime.

Developer's Certificate of Origin 1.1 is acknowledged and agreed to.

@achaljhawar achaljhawar requested review from a team as code owners May 14, 2025 20:47
@netlify
Copy link
Copy Markdown

netlify Bot commented May 14, 2025

Deploy Preview for expressjscom-preview ready!

Name Link
🔨 Latest commit 2a0f9e9
🔍 Latest deploy log https://app.netlify.com/projects/expressjscom-preview/deploys/685034fb2bb48100086eeb25
😎 Deploy Preview https://deploy-preview-1903--expressjscom-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread en/guide/migrating-5.md Outdated
@achaljhawar achaljhawar requested a review from bjohansebas May 16, 2025 16:03
@achaljhawar
Copy link
Copy Markdown
Contributor Author

@bjohansebas I have added it back

Comment thread en/guide/migrating-5.md Outdated
Comment thread en/guide/migrating-5.md Outdated
@achaljhawar
Copy link
Copy Markdown
Contributor Author

@bjohansebas I have done the changes you asked me to do.

@achaljhawar achaljhawar requested a review from bjohansebas May 17, 2025 06:47
@ShubhamOulkar ShubhamOulkar merged commit 722fb07 into expressjs:gh-pages Jun 23, 2025
9 checks passed
@ShubhamOulkar
Copy link
Copy Markdown
Member

Thank you @achaljhawar

Comment thread en/guide/migrating-5.md
Comment on lines +359 to +364
- JavaScript files (.js): now served as "text/javascript" instead of "application/javascript"
- JSON files (.json): now served as "application/json" instead of "text/json"
- CSS files (.css): now served as "text/css" instead of "text/plain"
- HTML files (.html): now served as "text/html; charset=utf-8" instead of just "text/html"
- XML files (.xml): now served as "application/xml" instead of "text/xml"
- Font files (.woff): now served as "font/woff" instead of "application/font-woff"
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.

Almost everything in this section is incorrect. Of all listed extensions only one has a different mime type - .js changed from application/javascript to text/javascript. HTML, CSS, JS and JSON also always had charset specified in Content-Type, so this didn't change either.

Comment thread en/guide/migrating-5.md
Comment on lines +327 to +332
- JavaScript files (.js): now "text/javascript" instead of "application/javascript"
- JSON files (.json): now "application/json" instead of "text/json"
- CSS files (.css): now "text/css" instead of "text/plain"
- XML files (.xml): now "application/xml" instead of "text/xml"
- Font files (.woff): now "font/woff" instead of "application/font-woff"
- SVG files (.svg): now "image/svg+xml" instead of "application/svg+xml"
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.

Same problems as in #1903 (comment)

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.

4 participants