Skip to main content
The edge context provides information about how a request arrived—the network path, protocols, and infrastructure. Use it for security decisions, performance optimization, and debugging.

Overview

The edge context is available on every AgentExecutionContext:

Datacenter Information

Know which Cloudflare datacenter is serving the request:

Common Datacenter Codes

Network Detection

Identify the network provider (ASN) for security and routing decisions:

Cloud Provider Detection

Detect if the request originates from a known cloud provider:
Detected cloud providers:

VPN Detection

Detect if the request comes from a known VPN provider:
VPN detection is based on ASN matching and is not foolproof. Many VPNs use residential or cloud IP addresses that won’t be detected.

Protocol Information

Check HTTP and TLS protocol details:

Protocol Helpers

Use Cases

Bot & Scraper Detection

Requests from cloud providers often indicate automated traffic:

Security Logging

Log edge information for security audits:

Feature Detection

Enable features based on client capabilities:

Multi-Region Debugging

Debug latency issues by checking which datacenter served the request:

TypeScript Types

Import the EdgeContext type:

Edge vs Location

Both contexts come from Cloudflare’s request.cf, but serve different purposes: Use them together for comprehensive request intelligence:

Next Steps

Location Context

Geographic and jurisdiction data

Security

Authentication and authorization

Operations

Available operation types

Testing

Testing and observability