Express 5 changes several res.sendFile options, mirroring the express.static
changes:
The dotfiles option now also applies to hidden directories in the path, not
just hidden files. In Express 4 a hidden directory in the path was served by
default; Express 5 returns a 404 Not Found unless you opt in with dotfiles: 'allow'.
The hidden option is removed and replaced by dotfiles.
The from option (an undocumented alias for root) is removed and replaced by root.
This codemod updates res.sendFile() calls to preserve the Express 4 behavior:
Adds an explicit dotfiles: 'allow' option to calls that don't already specify a dotfiles (or hidden) option.
After running this codemod, review each res.sendFile() call to determine if
serving dotfiles is actually necessary for your application. If you don't need to
serve dotfiles, you can:
Remove the dotfiles: 'allow' option to use the new Express 5 default ("ignore")
Or explicitly set dotfiles: 'deny' to return a 403 Forbidden for dotfile requests
Note that passing a root option scopes the dotfiles check to the part of the
path relative to root, so a hidden directory in root itself is unaffected.