Skip to content
Docs
Changelog

The Worker entry forwards the request id and the client address

One module derives a request's id and trusted client address, the Worker entry calls it once and every handler receives the result; a test keeps cf-ray and cf-connecting-ip out of handlers.

Markdown

  • One place derives, the entry forwards. deriveRequestFacts in packages/auth/src/request-runtime.ts reads Cloudflare's ray id and the client address (cf-connecting-ip on Workers, the configured proxy hop or the socket on Node). apps/web/src/server.ts calls it once per request and hands the result to the request runtime; the oRPC and MCP contexts, the Better Auth handler, the analytics relay and the Web Vitals limiter ask requestFacts(request). Rate limits, audit rows and the x-request-id header keep their values. See backend conventions. (48467b8)
  • Two readers now agree with the rest. The Web Vitals limiter read cf-connecting-ip itself; it counts under the same trusted address as every other limit (unchanged on Workers, where the limiter runs). An unhandled error reported to the tracker was tagged with the ray id only when Cloudflare sent one; it now carries the request id of the x-request-id header in every case (tagRequest).
  • A smaller interface. createAuth(...).handler no longer takes trustedClientIp: a request built in-process for the one being served (the MCP JWKS read) is counted under that request's address without the caller passing it. @template-cloudflare/auth/client-ip is no longer exported; @template-cloudflare/auth/request-runtime is, and W17 now lists two web modules with backend access, since server.ts only needs the runtime.
  • A test keeps it that way. scripts/request-facts.test.mjs fails when another module reads cf-ray or cf-connecting-ip, or when anything but the entry calls deriveRequestFacts.
Edit on GitHubDocumentation is in English.
Cookie settings
We use essential cookies to make our app work. With your consent, we also use optional cookies to improve your experience.

Read our Cookie Policy and Privacy Policy.