From 04a7431dfa24dd0ee4ff010b066746ee63ab21a1 Mon Sep 17 00:00:00 2001 From: 22BRS1317 Date: Tue, 17 Mar 2026 00:40:46 +0530 Subject: [PATCH 1/3] docs: add send options and methods changes to Express 5 migration guide (#1868) --- en/guide/migrating-5.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/en/guide/migrating-5.md b/en/guide/migrating-5.md index 4541a282c9..e79a827b04 100755 --- a/en/guide/migrating-5.md +++ b/en/guide/migrating-5.md @@ -56,8 +56,10 @@ You can find the list of available codemods [here](https://codemod.link/express)
  • res.send(body, status)
  • res.send(status)
  • res.sendfile()
  • +
  • res.sendFile() and express.static() options
  • router.param(fn)
  • express.static.mime
  • +
  • Removed send methods
  • express:router debug logs
  • @@ -402,6 +404,22 @@ const mime = require('mime-types') mime.lookup('json') ``` +

    res.sendFile() and express.static() options

    + +The following options to the `res.sendFile()` and `express.static()` functions are no longer supported: + +* `hidden`: Use the `dotfiles` option instead. +* `from`: Use the `root` option instead. + +

    Removed send methods

    + +The `send` package no longer exports the following methods. If your app relies on them, replace them with properties in the `options` object for `res.sendFile()` and `express.static()`: + +* `send.etag()`: Use the `etag` option instead. +* `send.index()`: Use the `index` option instead. +* `send.maxage()`: Use the `maxAge` option instead. +* `send.root()`: Use the `root` option instead. +

    express:router debug logs

    In Express 5, router handling logic is performed by a dependency. Therefore, the From 3b6fc97da7b9c8f42d26f10263d3b0adb74d7a4a Mon Sep 17 00:00:00 2001 From: 22BRS1317 Date: Wed, 18 Mar 2026 21:37:22 +0530 Subject: [PATCH 2/3] docs: remove internal send methods section from migration guide --- en/guide/migrating-5.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/en/guide/migrating-5.md b/en/guide/migrating-5.md index e79a827b04..e9571ace42 100755 --- a/en/guide/migrating-5.md +++ b/en/guide/migrating-5.md @@ -59,7 +59,6 @@ You can find the list of available codemods [here](https://codemod.link/express)
  • res.sendFile() and express.static() options
  • router.param(fn)
  • express.static.mime
  • -
  • Removed send methods
  • express:router debug logs
  • @@ -411,15 +410,6 @@ The following options to the `res.sendFile()` and `express.static()` functions a * `hidden`: Use the `dotfiles` option instead. * `from`: Use the `root` option instead. -

    Removed send methods

    - -The `send` package no longer exports the following methods. If your app relies on them, replace them with properties in the `options` object for `res.sendFile()` and `express.static()`: - -* `send.etag()`: Use the `etag` option instead. -* `send.index()`: Use the `index` option instead. -* `send.maxage()`: Use the `maxAge` option instead. -* `send.root()`: Use the `root` option instead. -

    express:router debug logs

    In Express 5, router handling logic is performed by a dependency. Therefore, the From ad02f4ad86767971866ab01f5b20c9a4839368ed Mon Sep 17 00:00:00 2001 From: 22BRS1317 Date: Sun, 22 Mar 2026 22:04:33 +0530 Subject: [PATCH 3/3] Update migrating-5.md based on review comments --- _includes/github-edit-btn.html | 4 ++-- en/guide/migrating-5.md | 32 +++++++++++++------------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/_includes/github-edit-btn.html b/_includes/github-edit-btn.html index 3c90f515b8..db032430bf 100644 --- a/_includes/github-edit-btn.html +++ b/_includes/github-edit-btn.html @@ -1,8 +1,8 @@ {% include icons/github.svg %} Edit this page diff --git a/en/guide/migrating-5.md b/en/guide/migrating-5.md index e9571ace42..4e379ce318 100755 --- a/en/guide/migrating-5.md +++ b/en/guide/migrating-5.md @@ -58,7 +58,7 @@ You can find the list of available codemods [here](https://codemod.link/express)
  • res.sendfile()
  • res.sendFile() and express.static() options
  • router.param(fn)
  • -
  • express.static.mime
  • +
  • res.sendFile() and express.static() MIME type detection
  • express:router debug logs
  • @@ -68,7 +68,7 @@ You can find the list of available codemods [here](https://codemod.link/express)
  • Path route matching syntax
  • Rejected promises handled from middleware and handlers
  • express.urlencoded
  • -
  • express.static dotfiles
  • +
  • res.sendFile() and express.static() dotfiles
  • app.listen
  • app.router
  • req.body
  • @@ -345,14 +345,7 @@ app.get('/user', (req, res) => { The `res.sendfile()` function has been replaced by a camel-cased version `res.sendFile()` in Express 5. -**Note:** In Express 5, `res.sendFile()` uses the `mime-types` package for MIME type detection, which returns different Content-Type values than Express 4 for several common file types: - -- 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" +**Note:** See the [MIME type detection](#express.static.mime) section for changes to Content-Type values in Express 5. {% capture codemod-camelcase-sendfile %} You can replace the deprecated signatures with the following command: @@ -380,19 +373,20 @@ app.get('/user', (req, res) => { The `router.param(fn)` signature was used for modifying the behavior of the `router.param(name, fn)` function. It has been deprecated since v4.11.0, and Express 5 no longer supports it at all. -

    express.static.mime

    +

    res.sendFile() and express.static() MIME type detection

    In Express 5, `mime` is no longer an exported property of the `static` field. Use the [`mime-types` package](https://github.com/jshttp/mime-types) to work with MIME type values. **Important:** This change affects not only direct usage of `express.static.mime` but also other Express methods that rely on MIME type detection, such as `res.sendFile()`. The following MIME types have changed from Express 4: -- 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" +- 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" +- HTML files (.html): now "text/html; charset=utf-8" instead of just "text/html" +- 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" ```js // v4 @@ -501,9 +495,9 @@ Details of how Express handles errors is covered in the [error handling document The `express.urlencoded` method makes the `extended` option `false` by default. -

    express.static dotfiles

    +

    res.sendFile() and express.static() dotfiles

    -In Express 5, the `express.static` middleware's `dotfiles` option now defaults to `"ignore"`. This is a change from Express 4, where dotfiles were served by default. As a result, files inside a directory that starts with a dot (`.`), such as `.well-known`, will no longer be accessible and will return a **404 Not Found** error. This can break functionality that depends on serving dot-directories, such as Android App Links, and Apple Universal Links. +In Express 5, the `res.sendFile()` function and the `express.static` middleware's `dotfiles` option now defaults to `"ignore"`. This is a change from Express 4, where dotfiles were served by default. As a result, files inside a directory that starts with a dot (`.`), such as `.well-known`, will no longer be accessible and will return a **404 Not Found** error. This can break functionality that depends on serving dot-directories, such as Android App Links, and Apple Universal Links. Example of breaking code: