Skip to content

Define source origins

Transformation URLs fetch source images before applying optimizations.

By default, Images accepts sources images only from the same zone where it serves the transformation. Use an allowlist to control the origins where /cdn-cgi/image/ transformation URLs can fetch source images.

Configure allowed origins

Before you can specify an allowlist, you must enable transformation URLs for the zone or Worker that serves them.

Configure allowed origins at the same scope as the URL interface.

Zone

Interface Setting
Wrangler Not available
Cloudflare CLI cf zones transformations-allowed-origins edit
Dashboard Images > Transformations > Sources
REST API transformations_allowed_origins

Worker

Interface Setting
Wrangler images.url_transformations.allowed_origins
Cloudflare CLI worker.images.urlTransformations.allowedOrigins
Dashboard Not available
REST API allowed_origins

How the allowlist works

Cloudflare rejects a transformation request when the source does not match the active allowlist.

The same hostname, wildcard, path, and redirect behaviors apply to both zone-scoped and Worker-scoped allowlists in production.

For zone-scoped transformations without an allowlist, Images accepts sources from any hostname in the same zone, including subdomains.

For custom domains routed to a Worker, the Worker's allowed_origins list replaces the zone-scoped allowlist handled by that Worker.

Match hostnames and subdomains

Each hostname in an allowlist matches only that exact hostname unless you use a wildcard.

Allowed origin Accepted source hostnames Rejected source hostnames
b.com b.com media.b.com, cdn.b.com
media.b.com media.b.com b.com, cdn.b.com
*.b.com b.com, media.b.com, cdn.b.com example.com

Add *. before a domain to match the domain and all of its subdomains.

Match paths

You can restrict an allowed origin to a path. If you omit the path, then Images accepts source images from every path on that hostname.

Cloudflare matches the configured path against the beginning of the source path.

Allowed origin Source URL Result
b.com/themes https://b.com/themes/image.png Accepted
b.com/themes https://b.com/themes/icons/image.png Accepted
b.com/themes https://b.com/media/themes/image.png Rejected

Follow redirects

Cloudflare checks the initial source URL against the allowed origins. After accepting the initial URL, Images follows redirects and processes the resulting image even when they lead to an origin that is not allowed.

Only allow hostnames whose redirects you trust.

Allow any origin

To accept publicly available source images from any origin:

Zone

  • Cloudflare CLI: Set the value to "*":
cf zones transformations-allowed-origins edit \
   --zone example.com \
   --value "*"

Changing a zone to accept any origin clears its allowlist.

Worker

  • Wrangler: Set allowed_origins = ["*"].
  • Cloudflare CLI: Set allowedOrigins: ["*"] in cloudflare.config.ts.
  • REST API: Set allowed_origins to ["*"] in the Worker transformation settings request.

For Worker configuration, "*" must be the only entry in the list.

Was this helpful?