LIVE PULSE
Back to journal
•6 min read•By Md. Wahidur Rahman Puson

How Wildcard Subdomain Routing Works at the Edge

A deep dive into how Next.js edge middleware and Cloudflare DNS wildcards combine to route dynamic subdomains in under 15ms without cold starts.

Traditional multi-tenant web systems require re-configuring reverse proxies or reloading web server configuration tables every time a new tenant signs up. This creates operational lag and increases the surface area for deployment failure.

In the ZenVQ architecture, we utilize Cloudflare's wildcard DNS capability (*.zenvq.com) pointing directly to an edge deployment running Next.js middleware.

When a request arrives, the edge middleware extracts the host header, sanitizes the tenant identifier against RFC 1123 host naming rules, and evaluates tenant validity. If valid, the request is rewritten internally to the tenant route (/sites/[subdomain]) while preserving the original public URL in the browser address bar.

This architecture eliminates manual DNS configuration, ensures near-zero cold start latency across global edge points of presence, and provides dependable isolation between tenant namespaces.