Skip to content

MagicStaticRoute

Source: src/Cloudflare/MagicTransit/StaticRoute.ts

A Magic Transit / Magic WAN static route — steers traffic for a prefix to a next-hop (usually a Magic tunnel interface address).

Requires a Magic Transit or Magic WAN subscription on the account — accounts that are not onboarded receive a typed MagicTransitNotOnboarded error (Cloudflare code 1012).

All properties are mutable in place via PUT. A route’s practical identity is the (prefix, nexthop, priority) triple — when state is lost, read scans for a matching route and reports it as Unowned so takeover is gated behind --adopt.

Route a prefix over a GRE tunnel

const tunnel = yield* Cloudflare.GreTunnel("office", {
name: "office-gre-1",
cloudflareGreEndpoint: "203.0.113.1",
customerGreEndpoint: "198.51.100.1",
interfaceAddress: "10.213.0.8/31",
});
yield* Cloudflare.MagicStaticRoute("office-route", {
prefix: "10.100.0.0/24",
nexthop: "10.213.0.9",
priority: 100,
});

ECMP route scoped to a region

yield* Cloudflare.MagicStaticRoute("ecmp-route", {
prefix: "10.100.0.0/24",
nexthop: "10.213.0.9",
priority: 100,
weight: 50,
scope: { coloRegions: ["ENAM"] },
});