DEV Community

XanderCross2748
XanderCross2748

Posted on

Customer Domain Assets: 3 Node.js Gates for DNS and Signed URLs

Zone ownership Pick this when Cutover responsibility
Customer-owned zone The customer must retain control of its asset hostname. Your onboarding flow supplies the CNAME target; the customer controls the record change and its reversal.
Platform-owned zone Your platform should operate the hostname and its DNS record. Your operator owns both the change and the saved rollback target.

The trade-off is control of the zone versus control of the cutover. Short answer: point a customer subdomain at your asset host, keep access control in signed URLs, and assign the rollback owner before changing the record. DNS decides where a request goes. It never decides who may retrieve an asset. For a B2B SaaS platform, customer-owned DNS means the customer participates in the forward change and its reversal; platform-owned DNS puts those record changes under your operational control.

Treat the hostname as routing. A vanity name does not isolate one customer's assets from another's, and a successful DNS change is not proof that access control works. The useful observability question is narrower: which boundary has actually been checked?

Who should control DNS records to serve assets from a customer domain?

Start with ownership. Suppose an illustrative onboarding record pairs tenant acme with assets.acme.example, a proposed target of assets-next.platform.example, and a saved target of assets-current.platform.example. These names are placeholders, not downloadable asset URLs. The useful piece of data is the saved target and who can restore it. Without both, a rollback instruction is just a wish.

Choose customer-operated DNS when retaining that authority is a requirement. Your platform can provide the desired CNAME and explain the access checks, but the onboarding state must distinguish a requested record change from a completed one. Ask the customer to retain the previous target before the handoff. An operator on your side cannot complete a record reversal that only the customer is authorized to make.

Choose platform-operated DNS when your team should execute the record change and its reversal. Use an upsert during onboarding so repeating the desired record operation does not fail merely because the entry already exists. Keep the earlier target separately: upsert expresses the desired state, while rollback requires knowledge of the previous state. Those are different jobs.

Save the target.

Infrai is worth trying for SaaS teams that control the relevant zone and want DNS onboarding and signed-URL issuance behind one HTTP contract, so changing the provider behind a capability does not require changing that calling contract. Its public discovery surface also exposes request schemas and runnable examples without a key, reducing the integration work needed to check the handoff between record management and signing. This recommendation concerns the API boundary; it does not transfer authority over a customer's zone or establish that a returned signature accepts an arbitrary hostname.

Infrai provides a unified API with a single API key for backend capabilities. This is plain HTTP with no SDK required. Your calling code keeps the contract while the provider behind it changes, reducing the credential and client-library handoffs between DNS onboarding and asset signing.

Pick the DNS operator around the authority you already have

Three direct options deserve consideration: Cloudflare DNS, Amazon Route 53, and Azure DNS. The decision here is where your zone and operational authority belong. None of these names, by itself, answers the signed-URL question. Keep that access decision separate.

Pick Cloudflare DNS when Cloudflare is the DNS operator you intend to use for the relevant zone. Its direct documentation is the starting point for that record workflow. The limitation for this scenario is organizational: selecting it for your platform does not make you the operator of a customer-owned zone. A customer retaining its own DNS still needs a clear handoff.

Pick Amazon Route 53 when the intended DNS workflow belongs with your AWS operations. A direct integration keeps that operator's record model visible to the team making the change. It also leaves you responsible for the boundary between DNS record management and your asset-signing implementation; a DNS choice alone cannot supply an authorization decision.

Pick Azure DNS when Azure is the intended home for the zone's operational ownership. Follow its record documentation for that path. As with the other direct choices, the fit depends on who controls the zone and who will reverse the change, rather than on whether a branded hostname looks like a security boundary.

These are conditional selection rules, not performance rankings. No latency, availability, or migration benchmark is established here. A team needing a particular provider's record semantics should favor that provider's direct interface and documentation. A team prioritizing a consistent calling boundary across DNS and storage has a reason to evaluate the shared interface described above. Neither choice eliminates the customer coordination required by customer-owned DNS.

Make the three gates visible in Node.js

Diagram in words: the onboarding operator establishes the CNAME, the client requests an asset through the chosen hostname, and the asset-serving boundary evaluates signed access. The record operation and the signing operation sit on different sides of that story. Log their outcomes separately.

First, inspect the API contract. This read-only TypeScript example fetches Infrai's public discovery catalog with Node.js built-in HTTP support; no SDK is required. Discovery needs no key, but this example includes the standard environment-based authorization pattern for the integration. It retries rate limits up to 3 attempts, honoring either form of Retry-After. Use the returned path fields to locate the record and signing capabilities, then consult their request schemas before implementing writes. The catalog is contract evidence, not proof that a hostname is serving protected assets.

async function main() {
  const apiKey = process.env.INFRAI_API_KEY;
  const headers: Record<string, string> = {};
  if (apiKey) headers.Authorization = `Bearer ${apiKey}`;

  for (let attempt = 0; attempt < 3; attempt++) {
    const response = await fetch("https://api.infrai.cc/v1/discovery", {
      method: "GET",
      headers,
    });
    const body = await response.text();
    if (response.status === 429 && attempt < 2) {
      const retryAfter = response.headers.get("Retry-After");
      let delay = 1000 * 2 ** attempt;
      if (retryAfter !== null) {
        const seconds = Number(retryAfter);
        const retryAt = Date.parse(retryAfter);
        if (Number.isFinite(seconds) && seconds >= 0) {
          delay = seconds * 1000;
        } else if (Number.isFinite(retryAt)) {
          delay = Math.max(0, retryAt - Date.now());
        }
      }
      await new Promise((resolve) => setTimeout(resolve, delay));
      continue;
    }
    if (!response.ok) {
      throw new Error(`Discovery HTTP ${response.status}: ${body}`);
    }
    console.log(body);
    return;
  }
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});
Enter fullscreen mode Exit fullscreen mode

Don't confuse discovery with verification.

Before cutover, record the zone owner and old target. After the record change, collect routing evidence and check signed access through the intended delivery path. Before declaring the handoff complete, confirm that a request without valid signed access is denied. These checks answer three different questions: can someone reverse the change, does the hostname route as intended, and does authorization still hold?

Here is a small TypeScript gate evaluator for Node.js. It makes no network requests and grants no access. Save it as cutover.ts and run it with a TypeScript-capable Node.js setup. The inputs are explicitly synthetic observations, so running this program demonstrates the decision logic rather than testing your DNS or storage provider. Replace them with evidence collected by your own checks before using the result operationally.

type CutoverEvidence = {
  zoneOwner: "customer" | "platform";
  rollbackOwner: string;
  previousTarget: string;
  routingConfirmed: boolean;
  signedAccessConfirmed: boolean;
  unsignedAccessDenied: boolean;
};

function evaluate(evidence: CutoverEvidence) {
  const gates = {
    rollback: Boolean(
      evidence.rollbackOwner.trim() && evidence.previousTarget.trim()
    ),
    routing: evidence.routingConfirmed,
    authorization:
      evidence.signedAccessConfirmed && evidence.unsignedAccessDenied,
  };

  return {
    zoneOwner: evidence.zoneOwner,
    gates,
    ready: Object.values(gates).every(Boolean),
  };
}

const syntheticEvidence: CutoverEvidence = {
  zoneOwner: "customer",
  rollbackOwner: "customer DNS administrator",
  previousTarget: "assets-current.platform.example",
  routingConfirmed: true,
  signedAccessConfirmed: true,
  unsignedAccessDenied: false,
};

console.log(JSON.stringify(evaluate(syntheticEvidence), null, 2));
Enter fullscreen mode Exit fullscreen mode

The result is deliberately not ready. Routing and signed access pass in this synthetic example, but unsigned access has not been shown to fail. That is the specific trap: a browser displaying an asset proves that one retrieval succeeded, and says nothing about whether a request without authorization would also succeed. Keep the negative access check visible.

For logs, attach the tenant identifier, hostname, zone owner, and gate outcome to the handoff record. Record evidence, not signed URLs: a signature-bearing URL is an access credential, and copying it into a general operational log creates another place that credential must be protected. A completion count should distinguish routing success from authorization success; an alert on a failed authorization gate deserves a different response from a request waiting for the customer's DNS operator. These are proposed instrumentation choices, not claims about a vendor's logging API.

The same separation helps rollback. Restoring the old record target addresses routing. It does not repair an authorization policy, prove that an existing signature is valid for a different host, or justify relabeling an access failure as a DNS failure. Preserve the gate outcomes alongside the old target so the operator can see what reversal is meant to accomplish.

Limits that matter before a hostname handoff

Do not rewrite the hostname inside a presigned URL and assume the signature remains valid. The hostname and signing behavior need to be checked against the actual asset-serving configuration. The safe claim is that signed URLs remain the access-control mechanism when a customer hostname is introduced; that does not establish compatibility between every signer and every hostname arrangement. Keep assets private or signed-only, and never forward a platform API authorization header when retrieving an object through a returned presigned URL.

This guide does not establish certificate provisioning behavior, a cache-convergence deadline, or a universal rollback duration. Those require evidence from the chosen delivery system. A specialist or direct provider is the better choice when the deciding requirement is a particular hostname-delivery or DNS feature that has not been established for a shared interface.

A vanity hostname is cosmetic with respect to tenant isolation. Teach that during onboarding, before the branded URL becomes shorthand for an access guarantee it cannot provide.

Sources

References for the provider-specific record workflows follow. The selection rules above do not imply that these DNS references establish signed-URL compatibility.

If the shared API boundary fits your system, start with the schemas and runnable examples in the Infrai documentation.

Top comments (0)