Skip to content

[wrangler] Add images.url_transformations config [Part 1] - #16679

Merged
petebacondarwin merged 3 commits into
cloudflare:mainfrom
mglewis:mattl/IMAGES-2395-images-url-transformations-config
Nov 20, 2026
Merged

petebacondarwin merged 3 commits into
cloudflare:mainfrom
mglewis:mattl/IMAGES-2395-images-url-transformations-config

Conversation

@mglewis

@mglewis mglewis commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Fixes IMAGES-2395 (internal).

Overview

/cdn-cgi/image/ URL transformations can only be configured per zone, this change introduces new config that will allow users to override zone level configuration and let an individual worker control this setting for the requests it serves.

The plan is for the setting to live alongside the existing config used by the images binding

{
	"images": {
		"binding": "IMAGES", // now optional
		"url_transformations": {
			"enabled": true,
			"allowed_origins": ["images.example.com"], // optional, ["*"] for any origin
		},
	},
}

This PR adds the code for config and validation. Followup changes apply this setting via a public api call on deploy (#16680) and add basic /cdn-cgi/image/ support in local dev (#16678), both stacked on this PR.

Changes

  • images.binding is now optional, and the images config block gains a url_transformations object (enabled required, allowed_origins optional)
  • images now has its own validator. It errors if:
    • neither binding nor url_transformations is set (so {} still fails, as it did before)
    • enabled is missing, or allowed_origins isn't an array of strings
    • "*" is mixed with other origins
    • allowed_origins breaks the basic rules of the zone-level setting (hostnames without a protocol, at most 10, not empty)
  • Like the rest of the images block, url_transformations isn't inherited by named environments. Wrangler warns if the top level sets it but an environment's images block doesn't
  • url_transformations can't be set inside the previews block. Preview deployments created with wrangler preview don't apply it. The images binding setting is supported.
  • An images block without a binding no longer produces a binding, and wrangler types skips it rather than erroring about the missing binding field

Reviewer Considerations

  • images now holds both a runtime binding and a per-Worker deploy-time setting. From a customer's perspective these are the same product, although as the underlying technical implementations differ there are a few awkward spots in the code.
  • The main one of these is inheritance by named environments. I've opted to not inherit url_transformations, so it behaves like the binding and each environment says exactly what it gets, rather than having to reason about whether e.g. allowed_origins carries over
  • The existing images.remote setting only affects the binding

Testing

Unit tests

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation

@changeset-bot

changeset-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: caafba2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@cloudflare/workers-utils Minor
@cloudflare/config Minor
@cloudflare/codemods Minor
@cloudflare/deploy-helpers Patch
wrangler Minor
@cloudflare/autoconfig Patch
@cloudflare/build-output-utils Patch
@cloudflare/cli-shared-helpers Patch
@cloudflare/containers-shared Patch
@cloudflare/remote-bindings Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-plugin Patch
@cloudflare/workers-auth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@16679

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@16679

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@16679

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@16679

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@16679

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@16679

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@16679

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@16679

miniflare

npm i https://pkg.pr.new/miniflare@16679

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@16679

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@16679

@cloudflare/runtime-types

npm i https://pkg.pr.new/@cloudflare/runtime-types@16679

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@16679

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@16679

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@16679

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@16679

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@16679

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@16679

wrangler

npm i https://pkg.pr.new/wrangler@16679

commit: caafba2

@mglewis mglewis changed the title [wrangler] Add images.url_transformations config [wrangler] Add images.url_transformations config [Part 1] Nov 3, 2026
@mglewis
mglewis force-pushed the mattl/IMAGES-2395-images-url-transformations-config branch 2 times, most recently from ff03041 to 508cfe8 Compare November 4, 2026 14:43
@mglewis
mglewis marked this pull request as ready for review November 5, 2026 16:18
@workers-devprod
workers-devprod requested review from a team and cjol and removed request for a team November 5, 2026 16:18
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/images-url-transformations-config.md: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/preview/shared.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/binding-utils.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/config/environment.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/config/validation.ts: [@cloudflare/wrangler]
  • packages/workers-utils/tests/binding-utils.test.ts: [@cloudflare/wrangler]
  • packages/workers-utils/tests/config/validation/normalize-and-validate-config.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/type-generation.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/type-generation/index.ts: [@cloudflare/wrangler]

@clanky-the-clanker

clanky-the-clanker Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

This pull request's reviews are posted as pull request reviews: see the review of 8f9498cf.

devin-ai-integration[bot]

This comment was marked as resolved.

@mglewis
mglewis force-pushed the mattl/IMAGES-2395-images-url-transformations-config branch from 508cfe8 to 8f9498c Compare November 5, 2026 16:46
@petebacondarwin

Copy link
Copy Markdown
Contributor

clanker review

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Out of date: this review is of 8f9498cf; the pull request is now at caafba25. Someone with write access can comment clanky review (or clanker review or @clanky-the-clanker review) to review the new commits.

✅ Approved — No issues found. The change only adds config validation, the types and tests cover each new path, and the field does nothing at runtime yet.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

No issues found. The change is limited to config validation, and the new fields have no runtime effect yet.


📖 AGENTS.md: ✅ LGTM

No issues found.


📋 Code Quality: ✅ LGTM

No issues found.


⚡ Performance: ✅ LGTM

No issues found.


📝 Documentation: ✅ LGTM

No issues found.


Reviewed commit: 8f9498cf

@petebacondarwin
petebacondarwin marked this pull request as draft November 6, 2026 16:25
@mglewis
mglewis force-pushed the mattl/IMAGES-2395-images-url-transformations-config branch from 8a489d4 to e808b51 Compare November 16, 2026 15:44
@mglewis
mglewis marked this pull request as ready for review November 17, 2026 15:21
@workers-devprod

workers-devprod commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

devin-ai-integration[bot]

This comment was marked as resolved.

@mglewis
mglewis force-pushed the mattl/IMAGES-2395-images-url-transformations-config branch from e808b51 to 7fc94bb Compare November 17, 2026 16:38
@petebacondarwin
petebacondarwin force-pushed the mattl/IMAGES-2395-images-url-transformations-config branch from 7fc94bb to 710355b Compare November 19, 2026 14:28
@petebacondarwin
petebacondarwin force-pushed the mattl/IMAGES-2395-images-url-transformations-config branch from 710355b to bff89c5 Compare November 19, 2026 15:12

@petebacondarwin petebacondarwin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new images.url_transformations setting is exposed through Wrangler’s configuration, but the PR doesn’t update the separate @cloudflare/config path used by cloudflare.config.ts and cf CLI.

At the PR’s current commit:

  • The TypeScript config’s Images schema only accepts type and dev; transformation options would be rejected.
  • Its converter only produces binding and remote.
    Supporting cf needs corresponding public types, schema, conversion, and tests in packages/config, including configuration without an Images binding.

@github-project-automation github-project-automation Bot moved this from Untriaged to In Review in workers-sdk Nov 19, 2026

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from In Review to Approved in workers-sdk Nov 20, 2026
@petebacondarwin
petebacondarwin enabled auto-merge (squash) November 20, 2026 13:12
@petebacondarwin
petebacondarwin removed the request for review from cjol November 20, 2026 13:15
@petebacondarwin
petebacondarwin merged commit be6aa81 into cloudflare:main Nov 20, 2026
111 of 114 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Nov 20, 2026
brandhaug added a commit to brandhaug/b2b-saas-starter that referenced this pull request Nov 24, 2026
## pnpm-workspace.yaml (default)

## Dependency Updates

| Package | From | To | Type |
| --- | --- | --- | --- |
| `@cloudflare/vitest-plugin` | 1.8.5 | 1.9.0 | minor |
| `@cloudflare/workers-types` | 5.20261120.1 | 5.20261121.1 | minor |
| `miniflare` | 5.20261118.0-beta | 5.20261119.0-beta | minor |
| `wrangler` | 4.165.0 | 4.166.0 | minor |

## Release Notes

<details>
<summary><b>@<!---->cloudflare/vitest-plugin</b> (1.8.5 →
1.9.0)</summary>

### Minor Changes

- [#16174](cloudflare/workers-sdk#16174)
[`629f135`](cloudflare/workers-sdk@629f135)
Thanks [@<!---->james-elicx](https://github.com/james-elicx)! - Remove
the dependency on `wrangler`

The Vitest plugin no longer depends on `wrangler`. Reading the Wrangler
configuration file, generating Miniflare options, loading local
variables and serving the Pages `ASSETS` binding now use shared
workers-sdk packages that are bundled into the plugin. Installing the
plugin no longer installs `wrangler` as well. If your project runs the
`wrangler` CLI (for example `wrangler types`), add `wrangler` to your
own `devDependencies`.

### Patch Changes

- [#17031](cloudflare/workers-sdk#17031)
[`95fd4c2`](cloudflare/workers-sdk@95fd4c2)
Thanks [@<!---->dependabot](https://github.com/apps/dependabot)! -
Update `DEFAULT_COMPAT_DATE` to 2026-11-19

Use the bundled workerd release's compatibility date by default when
scaffolding new projects or when no compatibility date is configured.

- [#17043](cloudflare/workers-sdk#17043)
[`4f5b118`](cloudflare/workers-sdk@4f5b118)
Thanks [@<!---->petebacondarwin](https://github.com/petebacondarwin)! -
Update Undici to 7.30.2 to include upstream security fixes

This patch includes six upstream security fixes covering caching,
redirects, and Subresource Integrity verification. Update the shared
Undici dependency and matching types together so affected packages ship
the patched version.

- [#17035](cloudflare/workers-sdk#17035)
[`1b563db`](cloudflare/workers-sdk@1b563db)
Thanks [@<!---->petebacondarwin](https://github.com/petebacondarwin)! -
Fix remote bindings authentication with API tokens scoped to an
individual Worker

  Remote 

…[full
notes](https://github.com/cloudflare/workers-sdk/releases/tag/%40cloudflare/vitest-plugin%401.9.0)

</details>

<details>
<summary><b>miniflare</b> (5.20261118.0-beta →
5.20261119.0-beta)</summary>

### Minor Changes

- [#17016](cloudflare/workers-sdk#17016)
[`8f45554`](cloudflare/workers-sdk@8f45554)
Thanks [@<!---->edmundhung](https://github.com/edmundhung)! - Add
`unsafeIntrospectWorkflow()` and `unsafeIntrospectWorkflowInstance()`
for exported Workflows

They find a Workflow by its Worker's name and its class name, so code
running in Node.js can introspect a Workflow on `ctx.exports` that has
no `env` binding:

  ```ts
  const introspector = await mf.unsafeIntrospectWorkflow(
    "my-worker",
    "MyWorkflow"
  );
  ```

### Patch Changes

- [#17034](cloudflare/workers-sdk#17034)
[`8712fc5`](cloudflare/workers-sdk@8712fc5)
Thanks [@<!---->petebacondarwin](https://github.com/petebacondarwin)! -
Fix Local Explorer access through localhost subdomains

Miniflare now trusts `*.localhost` in Host and Origin checks for
`/cdn-cgi/` requests. This allows Local Explorer to load through
localhost subdomains without returning `403 Invalid Origin header` for
its module scripts and API requests.

- [#17031](cloudflare/workers-sdk#17031)
[`95fd4c2`](cloudflare/workers-sdk@95fd4c2)
Thanks [@<!---->dependabot](https://github.com/apps/dependabot)! -
Update `DEFAULT_COMPAT_DATE` to 2026-11-19

Use the bundled workerd release's compatibility date by default when
scaffolding new projects or when no compatibility date is configured.

- [#17031](cloudflare/workers-sdk#17031)
[`95fd4c2`](cloudflare/workers-sdk@95fd4c2)
Thanks [@<!---->dependabot](https://github.com/apps/dependabot)! -
Update dependencies of "miniflare", "wrangler"

  The following dependency versions have been updated:

  | Dependency                | From          | To            |
  | -----------------------

…[full
notes](https://github.com/cloudflare/workers-sdk/releases/tag/miniflare%405.20261119.0-beta)

</details>

<details>
<summary><b>wrangler</b> (4.165.0 → 4.166.0)</summary>

### Minor Changes

- [#16961](cloudflare/workers-sdk#16961)
[`bf7568a`](cloudflare/workers-sdk@bf7568a)
Thanks [@<!---->dario-piotrowicz](https://github.com/dario-piotrowicz)!
- Show configured trigger targets during experimental `wrangler triggers
deploy --dry-run`

Dry runs now print a "Would deploy" summary of routes, custom domains,
cron schedules, Queue producers and consumers, Workflows, event
triggers, and Email Routing addresses instead of exiting without a
summary. Explicitly empty cron schedules and Email Routing addresses are
shown as removals. The preview makes no API requests or authentication
checks; when workers.dev is enabled, it reports that setting without
looking up the account's subdomain.

- [#16679](cloudflare/workers-sdk#16679)
[`be6aa81`](cloudflare/workers-sdk@be6aa81)
Thanks [@<!---->mglewis](https://github.com/mglewis)! - Add
`images.url_transformations` to the Wrangler configuration

The `images` block now accepts a `url_transformations` object for
controlling `/cdn-cgi/image/` transformations on requests served by a
Worker. `enabled` is required, and `allowed_origins` optionally lists
the origins images may be fetched from (use `["*"]` to allow any
origin). `binding` is now optional, so `url_transformations` can be
configured without an Images binding:

  ```jsonc
  {
    "images": {
      "url_transformations": {
        "enabled": true,
        "allowed_origins": ["images.example.com"]
      }
    }
  }
  ```

Like the rest of the `images` block, `url_transformations` is not
inherited by named environments, and must be specified in each
environment that needs it.

`cloudflare.config.ts` gains the equivalent setting as a top-level
`images` field on the Worker, with the Images binding remaining in
`env`:

  ```ts
  export default defineConfig({
    worker: {
      name: "my-worker

…[full
notes](https://github.com/cloudflare/workers-sdk/releases/tag/wrangler%404.166.0)

</details>

---
*This PR was auto-generated by
[catalog-update-action](https://github.com/brandhaug/catalog-update-action).*

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants