Allow to manage custom hostnames (a.k.a. Cloudflare for SaaS)
import * as Cloudflare from "cloudflare-client";
// Initialize an HTTP client for interacting with Cloudflare API
const hostnames = Cloudflare.customHostnames({
zoneId: env.CLOUDFLARE_ZONE_ID,
accessToken: env.CLOUDFLARE_API_TOKEN,
});
// Create a new custom hostname
const hostname = await hostnames.create({ hostname: "app.koistya.com" });
// => { id: "xxx", hostname: "xxx", ownership_verification: ..., ... }
// Update hostname
await hostnames.update(hostname.id, { ssl: { ... } });
// Delete hostname
await hostnames.delete(hostname.id);
// Find hostnames
const records = await hostnames.find({ ... }).all();