Skip to content

feat: add DPRINT_ALLOWED_HOSTS env var for limiting the hosts to connect to - #1497

Merged
dsherret merged 4 commits into
mainfrom
allowed-hosts
Nov 30, 2026
Merged

dsherret merged 4 commits into
mainfrom
allowed-hosts

Conversation

@dsherret

@dsherret dsherret commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Adds a DPRINT_ALLOWED_HOSTS environment variable, which is a comma-separated list of the only hosts dprint may connect to. For example, to only download from npm:

export DPRINT_ALLOWED_HOSTS=registry.npmjs.org
  • Hosts are matched exactly. *.example.com matches the subdomains of a domain at any depth but not the domain itself, and * matches any host.
  • It only allows https. Any host is allowed when it's not set or empty.
  • It applies to every command and each redirect.
  • When a request goes through a proxy, the proxy's host needs to be in the list too, wherever it's from (HTTPS_PROXY, HTTP_PROXY, npm's environment variables, or an .npmrc). A host in NO_PROXY doesn't use one.
  • It only ever limits. Editors still ask before downloading from a domain that isn't trusted, and don't ask about a host that isn't allowed.
  • What's cached is still used, and --reload doesn't remove a cached plugin that can't be downloaded again.
  • Optional requests (ex. checking for a new version in --help) are skipped quietly.
  • dprint add <name> suggests an npm: specifier when plugins.dprint.dev isn't allowed.
  • A value that isn't valid (ex. a.*.com or one with a port) allows nothing and is warned about.

It doesn't limit what process plugins connect to or reading a file on another machine (ex. a UNC path on Windows).

@dsherret
dsherret merged commit 16149e2 into main Nov 30, 2026
6 checks passed
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.

1 participant