Skip to content

feat: add express.static dotfiles codemod#142

Open
singhvishalkr wants to merge 1 commit into
expressjs:mainfrom
singhvishalkr:feat/static-dotfiles-codemod
Open

feat: add express.static dotfiles codemod#142
singhvishalkr wants to merge 1 commit into
expressjs:mainfrom
singhvishalkr:feat/static-dotfiles-codemod

Conversation

@singhvishalkr
Copy link
Copy Markdown

In Express 5, the express.static middleware's dotfiles option defaults to "ignore" instead of serving them. This breaks functionality that depends on serving dot-directories like .well-known (used for Android App Links, Apple Universal Links, Let's Encrypt verification, etc.).

This PR adds a new codemod that explicitly sets dotfiles: 'allow' on express.static() calls that don't already specify a dotfiles option. A comment is included to flag the change for manual review.

The codemod:

  • Transforms express.static('public') to express.static('public', { dotfiles: 'allow' /* Express 5: preserve v4 behavior */ })
  • Preserves existing options when present
  • Skips calls that already have an explicit dotfiles setting

The README includes a security note encouraging developers to review each call and consider whether serving dotfiles is actually necessary.

Also added the new codemod to the v5-migration-recipe workflow.

Closes #116

Add a codemod that explicitly sets dotfiles: 'allow' on express.static()
calls to preserve Express 4 behavior where dotfiles were served by default.

In Express 5, the dotfiles option defaults to 'ignore', which can break
functionality that depends on serving dot-directories like .well-known
(used by Android App Links and Apple Universal Links).

Closes expressjs#116
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.

new codemod: express.static dotfiles

1 participant