Skip to content

geoIpFilter

geoIpFilter(config?): Policy

Defined in: src/policies/traffic/geo-ip-filter.ts:43

Block or allow requests based on geographic country code.

Reads the country from the configured header (default cf-ipcountry, set by Cloudflare). Supports allowlist and denylist modes. Country sets are pre-computed once at construction time for efficiency.

GeoIpFilterConfig

Country filter rules and mode selection.

Policy

A policy at priority 1 (IP_FILTER).

// Allow only US, Canada, and UK
geoIpFilter({ mode: "allow", allow: ["US", "CA", "GB"] });
// Block specific countries
geoIpFilter({ deny: ["CN", "RU"] });