pages

Integration guide

Regional DoH paths, split rules, and cache behavior.

DoH paths

Mainland China optimized:

https://your-domain/cn/dns-message

Global public resolution:

https://your-domain/global/dns-message

Both paths accept RFC 8484 GET ?dns= and POST application/dns-message. The browser console uses the same region's /dns-api?name=...&type=... JSON endpoint.

Mainland China split

The cn route uses only the synchronized ChinaMax_Domain.txt domain rules. The homepage maps the Cloudflare client country code to cn or global automatically; matching names use the private China upstream and other names use Cloudflare public DoH.

Cache

The cache key contains the region, selected upstream lane, and the normalized full DNS query message. The DNS message ID is restored at the edge for each request, so clients can share a cached response safely. The cache lifetime never exceeds the smallest TTL in the DNS response and is bounded by CACHE_MAX_TTL_SECONDS.

Configuration file

The upstream DoH URLs, service token, ruleset path, and cache limits are defined in backend/config.ts. Runtime environment variables and Cloudflare Pages Secrets are not read; this repository must remain Private.