Routing behavior:
OPTIONS is treated as a universal CORS preflight./mark-session-detection (POST) proxies to a Supabase Edge Function./put (POST) writes hostname routing configuration to KV for onboarding.Upstream selection:
/gtm/debug, /gtm/static, /gtm/preview) route to preview_origin_url when available.origin_url.Proxy rewriting:
/k/..., attempts to decode the p query param and rewrite the upstream URL.Incoming downstream request.
Worker environment bindings.
Cloudflare execution context for waitUntil.
Proxied response.
This handler does not explicitly throw; it returns Response objects for error conditions.
Main Worker
fetchhandler.