Load a configuration file and convert it to Caddy JSON format
Reads the file from disk, auto-detects the format (or uses the provided adapter), and uses Caddy's /adapt endpoint to convert it to JSON configuration.
Path to the configuration file
Optional
Adapter to use (auto-detected from extension if not provided)
Loading options (adminUrl, timeout)
The parsed Caddy configuration object
If the file content is empty or invalid
If Caddy cannot parse the configuration
If unable to connect to Caddy Admin API
If the request times out
// Auto-detect format from extensionconst config = await loadConfig("./config.json");// Explicitly specify adapterconst config = await loadConfig("./my-config", "caddyfile");// With custom Caddy URLconst config = await loadConfig("./Caddyfile", undefined, { adminUrl: "http://caddy:2019"}); Copy
// Auto-detect format from extensionconst config = await loadConfig("./config.json");// Explicitly specify adapterconst config = await loadConfig("./my-config", "caddyfile");// With custom Caddy URLconst config = await loadConfig("./Caddyfile", undefined, { adminUrl: "http://caddy:2019"});
Load a configuration file and convert it to Caddy JSON format
Reads the file from disk, auto-detects the format (or uses the provided adapter), and uses Caddy's /adapt endpoint to convert it to JSON configuration.