expressjs.com icon indicating copy to clipboard operation
expressjs.com copied to clipboard

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

Open achaljhawar opened this issue 6 months ago • 3 comments

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 avatar May 14 '25 20:05 achaljhawar

Deploy Preview for expressjscom-preview ready!

Name Link
Latest commit 2a0f9e99fed8dbaf0409841b35129b2ed5730c9a
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.

netlify[bot] avatar May 14 '25 20:05 netlify[bot]

@bjohansebas I have added it back

achaljhawar avatar May 16 '25 16:05 achaljhawar

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

achaljhawar avatar May 17 '25 06:05 achaljhawar

Thank you @achaljhawar

ShubhamOulkar avatar Jun 23 '25 10:06 ShubhamOulkar