Setup HTTPS for Local Development with Caddy
• ⏱︎ 1 min read
🎯 What Problem Are We Trying to Solve?
Install Caddy and NSS
Caddy handles the web server part, while NSS
manages SSL/TLS certificates for trusted HTTPS connections.
brew install caddy
brew install nss
Configure Your Project
In your project root, create a file called Caddyfile
with:
https://dev.local.com {
reverse_proxy localhost:4321
# 👋 Only suitable for local dev. Don't use in prod.
tls internal
}
Update /etc/hosts
127.0.0.1 dev.local.com
Run Your Site
Start the development server and Caddy in separate terminals:
npm run dev
caddy run
Reload Caddy after making configuration changes:
caddy reload --config Caddyfile
🧰 Troubleshooting
- DNS Issues: Ensure
/etc/hosts
is correctly set up. - TLS Warnings: Browser warnings about self-signed certificates are expected.