docs: document removed options for res.sendFile() and express.static() in Express 5 migration guide#2211
docs: document removed options for res.sendFile() and express.static() in Express 5 migration guide#221122BRS1317 wants to merge 2 commits intoexpressjs:redesignfrom
Conversation
👷 Deploy request for expressjscom-preview pending review.Visit the deploys page to approve it
|
There was a problem hiding this comment.
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.
|
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. |
|
Hi! I've addressed all the feedback:
Please let me know if any further changes are needed. Thank you! |
en/guide/migrating-5.md
Outdated
| - 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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
_includes/github-edit-btn.html
Outdated
| {{ 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 }} |
There was a problem hiding this comment.
I think @bjohansebas meant changing the PR base branch to redesign, not changing the edit button URL.
There was a problem hiding this comment.
Thank you for the review!
-
PR base branch — I have changed the base branch of this PR
fromgh-pagestoredesignas requested. -
SVG MIME type — After checking the Express 4 source code,
application/svg+xmlwas indeed the type used in Express 4,
so the change toimage/svg+xmlin Express 5 is accurate and
I have kept it in the documentation. -
Edit button — Reverted
_includes/github-edit-btn.html
back togh-pagessince the redesign branch is now the base
of the PR itself.
Please let me know if any further changes are needed. Thank you!
There was a problem hiding this comment.
- PR base branch — I have changed the base branch of this PR
fromgh-pagestoredesignas 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).
- SVG MIME type — After checking the Express 4 source code,
application/svg+xmlwas indeed the type used in Express 4,
so the change toimage/svg+xmlin 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.
There was a problem hiding this comment.
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!
|
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 |
|
@22BRS1317 now do the rebase |
Description
Fixes #1868
Changes made
en/guide/migrating-5.mdres.sendFile()and
express.static():hidden→ usedotfilesoption insteadfrom→ userootoption insteadMotivation
Developers upgrading from Express 4 to Express 5 who used the
hiddenor
fromoptions inres.sendFile()orexpress.static()wouldencounter 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
sendpackagemethods that were not part of the public Express API. This PR contains
only the user-facing option changes.