Serve /.well-known files by default#313
Open
kklem0 wants to merge 1 commit into
Open
Conversation
The 1.0 removal of the deprecated `hidden` option also removed the documented default of not ignoring files within dot directories, which silently broke RFC 8615 well-known URIs (ACME challenges, Android's assetlinks.json, Apple's apple-app-site-association) for consumers of the default dotfiles handling — while the README still documents the old default. Restore the safe subset of that behavior: when no explicit `dotfiles` option is provided, files within the top-level `.well-known` directory are served. Other dotfiles remain ignored, and an explicit `dotfiles` setting behaves exactly as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since 1.0, the default
dotfileshandling ignores every dot-segment path. The removal of the deprecatedhiddenoption ("Remove deprecated hidden option") also removed the long-standing default of not ignoring files nested inside dot directories — the behavior the README still documents today:So current
masterhas a code/docs mismatch, and the behavior change silently broke RFC 8615 well-known URIs for every consumer of the default (includingserve-static/express.staticin Express 5):/.well-known/acme-challenge/…, Let's Encrypt)/.well-known/assetlinks.json)/.well-known/apple-app-site-association)security.txt, OIDC discovery, and the rest of the well-known registryThese requests now 404 (or fall through to an app handler) with no diagnostics. Back in expressjs/serve-static#54, "don't ignore
.well-knownby default" was closed precisely because the old default served it — that resolution no longer holds.Fix
When no explicit
dotfilesoption is provided, serve files under the top-level.well-knowndirectory; everything else about dotfile handling is unchanged:/.git/config..well-known(e.g./.well-known/.hidden) is still ignored.parts[0] === '.well-known'), so/.well-known-evil/…gets no special treatment.dotfiles: 'allow' | 'deny' | 'ignore'behaves exactly as before — the exception only applies to the default.This matches what
sirvdoes by default (lukeed/sirv#50), and the README'sdotfilessection is updated to describe the new (narrower) exception instead of the removed pre-1.0 one.Testing
Added cases to the existing
dotfilessuite (all 143 tests pass, eslint clean):/.well-known/security.txt/.well-known/.hidden'ignore'404s/.well-known/security.txt'deny'403s/.well-known/security.txtSemver: this loosens default behavior, so it's presumably a minor (1.3.0) rather than a patch. Happy to adjust the approach (e.g. an opt-in option instead of a default) if the team prefers — though the default is what un-breaks
express.staticusers who can't pass options through, like@react-router/serve(see remix-run/react-router#15340).