GeoIP Redirect

Automatically route users to the closest or most appropriate content origin based on their geographic location using FastEdge's built-in GeoIP headers.

Features

Code

let country = req.headers()
    .get("geoip-country-code")
    .and_then(|v| v.to_str().ok())
    .unwrap_or("unknown");

match country {
    "DE" | "FR" | "NL" => redirect_to("https://eu.example.com"),
    "US" | "CA" => redirect_to("https://na.example.com"),
    _ => redirect_to("https://global.example.com"),
}