Static web publishing CLI tool for deploying web applications to a CDN with a single command
—
SSL certificate management including Let's Encrypt integration, custom certificate upload, and security configuration for HTTPS deployments.
Upload custom SSL certificates for domains (legacy method).
/**
* Upload custom SSL certificate for domain
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function ssl(hooks?: HookConfig): CommandFunction;CLI Usage:
# Interactive certificate upload
surge ssl
# Upload certificate for specific domain
surge ssl example.com cert.pem
# With domain and certificate file
surge ssl --domain example.com --pem cert.pemCertificate Requirements:
Library Usage:
surge.ssl({})(process.argv.slice(2));Provision SSL certificates automatically using Let's Encrypt.
/**
* Provision SSL certificate via Let's Encrypt
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function encrypt(hooks?: HookConfig): CommandFunction;CLI Usage:
# Provision SSL for domain
surge encrypt example.com
# Interactive domain selection
surge encryptLet's Encrypt Process:
Benefits:
Library Usage:
surge.encrypt({})(process.argv.slice(2));Display SSL certificate information for projects.
/**
* View SSL certificate information for project
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function certs(hooks?: HookConfig): CommandFunction;CLI Usage:
# View certificates for domain
surge certs example.com
# List all certificates
surge certsCertificate Information Displayed:
Library Usage:
surge.certs({})(process.argv.slice(2));All Surge domains automatically receive SSL certificates:
Wildcard Certificates:
Let's Encrypt Certificates:
Custom Certificates:
Configure automatic HTTPS redirection:
Surge automatically adds security headers:
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=blockConfigure CSP headers in your HTML:
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline';">Configure CORS for API access:
// In your application
const corsHeaders = {
'Access-Control-Allow-Origin': 'https://yourapp.surge.sh',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE',
'Access-Control-Allow-Headers': 'Content-Type, Authorization'
};For Let's Encrypt certificates, domain validation occurs via:
For custom domains with SSL:
surge encrypt command# Example custom domain setup
surge ./build customdomain.com
surge encrypt customdomain.comAutomatic Renewal:
Manual Renewal:
Monitor certificate status:
# Check certificate status
surge certs example.com
# List expiring certificates
surge certs --expiringCertificate Backup:
Recovery Process:
Certificate Not Trusted:
Domain Mismatch:
Expired Certificate:
Let's Encrypt Failures:
# Check certificate details
openssl x509 -in cert.pem -text -noout
# Test SSL connection
openssl s_client -connect example.com:443
# Verify certificate online
# Use SSL Labs SSL Test or similar toolsInstall with Tessl CLI
npx tessl i tessl/npm-surge