Skip to main content

TlsConfig

Node-only TLS configuration for custom certificate handling.

interface TlsConfig {
rejectUnauthorized?: boolean
ca?: string | string[]
}

Fields

FieldTypeDefaultDescription
rejectUnauthorizedbooleantrueWhether to reject connections with unverified certificates. Set to false for self-signed certs (development only).
castring | string[]undefinedPEM-encoded CA certificate(s) to trust. Use for internal/private CAs.

How it works

When tls is set in RequestConfig, parcely lazy-imports undici (installed via optionalDependencies) and creates a custom Agent with the specified TLS options. This agent is passed to fetch as a dispatcher.

Example

import { createClient } from '@parcely/core'
import { readFileSync } from 'node:fs'

// Self-signed cert (dev only)
const dev = createClient({
baseURL: 'https://localhost:3443',
tls: { rejectUnauthorized: false },
})

// Custom CA
const internal = createClient({
baseURL: 'https://api.internal.corp',
tls: { ca: readFileSync('/etc/ssl/internal-ca.pem', 'utf-8') },
})

Platform behaviour

RuntimeBehaviour
Node 20+Full support via undici.Agent
BrowsersIgnored; one-shot console.warn
BunIgnored; one-shot console.warn
DenoIgnored; one-shot console.warn

See also