npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vite-plugin-caddy-multiple-tls

v1.4.1

Published

Vite plugin that uses Caddy to provide local HTTPS with derived domains.

Downloads

1,485

Readme

vite-plugin-caddy-multiple-tls

What it does

Runs Caddy alongside Vite to give you HTTPS locally with automatic, per-branch domains like <repo>.<branch>.localhost, so you can use real hostnames, cookies, and secure APIs without manual proxy setup.

Usage

// vite.config.js
import { defineConfig } from 'vite';
import caddyTls from 'vite-plugin-caddy-multiple-tls';

const config = defineConfig({
  plugins: [
    caddyTls(),
  ]
});

export default config;

Will give this in the terminal, allow you to connect to your app on HTTPS with a self-signed and trusted cert.

> vite


🔒 Caddy is proxying your traffic on https

🔗 Access your local server
🌍 https://my-repo.my-branch.localhost

By default, the plugin derives <repo>.<branch>.localhost from git. If repo or branch can't be detected, pass repo/branch or use domain.

If you want a fixed host without repo/branch in the URL, pass a single domain:

// vite.config.js
import { defineConfig } from 'vite';
import caddyTls from 'vite-plugin-caddy-multiple-tls';

const config = defineConfig({
  plugins: [
    caddyTls({
      domain: 'app.localhost',
    })
  ]
});

export default config;

To derive a domain like <repo>.<branch>.<baseDomain> automatically from git (repo name first, then branch):

// vite.config.js
import { defineConfig } from 'vite';
import caddyTls from 'vite-plugin-caddy-multiple-tls';

const config = defineConfig({
  plugins: [
    caddyTls({
      baseDomain: 'local.conekto.eu',
    })
  ]
});

export default config;

You can override auto-detection with repo or branch if needed.

For a zero-config experience, use baseDomain: 'localhost' (the default) so the derived domain works without editing /etc/hosts.

internalTls defaults to true when you pass baseDomain or domain. You can override it if needed.

For non-.localhost domains (like local.example.test), keep internalTls: true to force Caddy to use its internal CA for certificates.

[!IMPORTANT]
Hosts file limitation: If you use a custom domain, you must manually add each generated subdomain to your /etc/hosts file (e.g., 127.0.0.1 repo.branch.local.example.test). System hosts files do not support wildcards (e.g., *.local.example.test), so you lose the benefit of automatic domain resolution that localhost provides.

Recommended base domain: .localhost

Why localhost is the best option for local development:

  • Reserved by RFC 6761 (never on the public internet).
  • Automatic resolution on macOS: *.localhost maps to 127.0.0.1 and ::1 without DNS or /etc/hosts.
  • Subdomain support: api.localhost, foo.bar.localhost, etc.
  • Secure context in browsers for HTTPS, service workers, and cookies.
  • Works well with Caddy and other local reverse proxies.

Example usage:

app.localhost
api.app.localhost

[!NOTE] Linux users: Unlike macOS, most Linux distributions don't automatically resolve *.localhost subdomains. The plugin will detect Linux and show you the exact command to run:

🐧 Linux users: if the domain doesn't resolve, run:
   echo "127.0.0.1 my-repo.my-branch.localhost" | sudo tee -a /etc/hosts

If you want to avoid /etc/hosts edits on Linux, set loopbackDomain to a public loopback domain:

caddyTls({
  loopbackDomain: 'localtest.me',
})

Supported values: localtest.me, lvh.me, nip.io (maps to 127.0.0.1.nip.io). These rely on public DNS, so they can fail offline or on restricted networks.

Why these work: they use wildcard DNS so any subdomain resolves to 127.0.0.1, meaning the request loops back to your machine after DNS.

  • localtest.me and lvh.me: static wildcard -> always 127.0.0.1 (great for subdomain testing).
  • nip.io: dynamic parsing of the IP in the hostname (e.g. app.192.168.1.50.nip.io) so you can target LAN devices. Why use them: subdomains behave like real domains, no /etc/hosts edits, and closer parity for cookies/CORS rules.

When using loopback domains, ensure your Vite config allows the Host header and binds to all interfaces, e.g. server: { allowedHosts: true, host: true }.

For a permanent fix that handles all *.localhost domains automatically, install dnsmasq:

sudo apt install dnsmasq
echo "address=/.localhost/127.0.0.1" | sudo tee /etc/dnsmasq.d/localhost.conf
sudo systemctl restart dnsmasq

Development

This repo uses npm workspaces. Install from the root with npm install, then run workspace scripts like npm run build --workspace packages/plugin or npm run dev --workspace playground.

Contributing

See CONTRIBUTING.md to see how to get started.

License

MIT