Skip to content

docs: document removed options for res.sendFile() and express.static() in Express 5 migration guide#2211

Open
22BRS1317 wants to merge 2 commits intoexpressjs:redesignfrom
22BRS1317:gh-pages
Open

docs: document removed options for res.sendFile() and express.static() in Express 5 migration guide#2211
22BRS1317 wants to merge 2 commits intoexpressjs:redesignfrom
22BRS1317:gh-pages

Conversation

@22BRS1317
Copy link

Description

Fixes #1868

Changes made

en/guide/migrating-5.md

  • Added new section documenting removed options for res.sendFile()
    and express.static():
    • hidden → use dotfiles option instead
    • from → use root option instead
  • Added TOC entry linking to the new section

Motivation

Developers upgrading from Express 4 to Express 5 who used the hidden
or from options in res.sendFile() or express.static() would
encounter silent breakage with no guidance in the migration guide.
This PR documents those removed options so users know what to replace
them with.

Note

Previous PR #2209 was closed due to including internal send package
methods that were not part of the public Express API. This PR contains
only the user-facing option changes.

@22BRS1317 22BRS1317 requested a review from a team as a code owner March 18, 2026 16:16
@netlify
Copy link

netlify bot commented Mar 18, 2026

👷 Deploy request for expressjscom-preview pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit ae918dc

Copy link
Contributor

@krzysdz krzysdz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be also mentioned for res.sendFile() that the default for dotfiles changed to "ignore". I think it could be merged with the "express.static dotfiles" section.

There's also the switch to mime-types (pillarjs/send#192), which affects res.sendFile() and express.static, but is mentioned (twice) in sections about res.sendfile() (lowercase f) and express.static.mime, so there's a (small) chance someone could miss it when looking only at the ToC. I'm not sure if this is something that really needs changing, but I'll leave it here for reviewers to decide.

By the way you don't have to close a PR and open a new one after pushing new commits. You could have kept #2209 and it would show the new changes automatically after updating source branch.

@bjohansebas
Copy link
Member

Aside from @krzysdz’s comments, this needs to be released for the new documentation. Since I don’t have time to do documentation backports, could you update the reference to the new redesign branch in this same PR? Otherwise, I’ll do it when I start modifying the documentation.

@22BRS1317
Copy link
Author

Hi! I've addressed all the feedback:

  • Removed the internal send.* methods section
  • Combined res.sendFile() and express.static() dotfiles
    into a single section, explicitly mentioning the new default
    value of "ignore"
  • Consolidated the duplicate MIME type documentation from
    res.sendfile() and express.static.mime sections into one
    dedicated section with updated TOC entry
  • Updated _includes/github-edit-btn.html to point to the
    redesign branch as requested

Please let me know if any further changes are needed. Thank you!

- 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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this really change? I looked at mime@1.6.0 types database and I see image/svg+xml as the type for .svg and .svgz extensions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I see that the duplicate sections weren't identical and one of them mentioned SVG. It turns out #1903 was vibecoded and is AI slop. 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 on lines +3 to +5
{{ site.github.repository_url }}/tree/redesign/_includes/api/en/{{page.version}}
{% else %}
{{ site.github.repository_url }}/edit/gh-pages/{{ page.path }}
{{ site.github.repository_url }}/edit/redesign/{{ page.path }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @bjohansebas meant changing the PR base branch to redesign, not changing the edit button URL.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review!

  1. PR base branch — I have changed the base branch of this PR
    from gh-pages to redesign as requested.

  2. SVG MIME type — After checking the Express 4 source code,
    application/svg+xml was indeed the type used in Express 4,
    so the change to image/svg+xml in Express 5 is accurate and
    I have kept it in the documentation.

  3. Edit button — Reverted _includes/github-edit-btn.html
    back to gh-pages since the redesign branch is now the base
    of the PR itself.

Please let me know if any further changes are needed. Thank you!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that’s what I meant.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done those changes

Copy link
Contributor

@krzysdz krzysdz Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. PR base branch — I have changed the base branch of this PR
    from gh-pages to redesign as requested.

You did not, but @bjohansebas did that for you 30 min ago. You'll need to rebase your branch on redesign (git rebase redesign).

  1. SVG MIME type — After checking the Express 4 source code,
    application/svg+xml was indeed the type used in Express 4,
    so the change to image/svg+xml in Express 5 is accurate and
    I have kept it in the documentation.

Please don't blindly trust LLMs. This is not something done by Express directly, but mime (Express 4) or mime-types (and mime-db) (Express 5). I sent you a direct link to the mime type and file extension mapping from mime@1.6.0, where you can find what type is used for .svg in Express 4. You could also run a simple server to verify that Express 4 did not use application/svg+xml, but something else.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback and sorry for the incorrect SVG claim.
I verified using mime@1.6.0 directly:

node -e "const mime = require('mime'); console.log(mime.lookup('svg'));"
// output: image/svg+xml

This confirms SVG already returned "image/svg+xml" in Express 4 so
it was not a change. I have removed that line.

I have also rebased the branch on upstream/redesign — the PR now
shows 1 file changed with only the relevant changes to
legacy/en/guide/migrating-5.md.

Sorry for the confusion earlier and thank you for your patience!

@bjohansebas
Copy link
Member

Note that I haven’t reviewed what this PR does, and I won’t do so until next weekend when I go on vacation to take the final steps of the redesign

@bjohansebas bjohansebas changed the base branch from gh-pages to redesign March 22, 2026 21:53
@bjohansebas
Copy link
Member

@22BRS1317 now do the rebase

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.

Add the changes in send to the migration guide

3 participants