Skip to content

[miniflare] Add local development support for /cdn-cgi/image/ URL transformations [Part 3] - #16678

Merged
petebacondarwin merged 9 commits into
cloudflare:mainfrom
mglewis:mattl/IMAGES-2346-cdn-cgi-image-local-transforms
Nov 30, 2026
Merged

petebacondarwin merged 9 commits into
cloudflare:mainfrom
mglewis:mattl/IMAGES-2346-cdn-cgi-image-local-transforms

Conversation

@mglewis

@mglewis mglewis commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Fixes IMAGES-2346 (internal).

Adds local dev support for /cdn-cgi/image/<options>/<source> URL transformations, driven by the images.url_transformations config from #16679 and applied on deploy by #16680 (both merged).

  • Miniflare handles /cdn-cgi/image/ before the Worker: 404 unless enabled, 403 if the source is neither same-zone nor in allowed_origins. It reuses the existing Sharp-backed cf.image mock for the transform
  • Redirects are checked against allowed_origins, credentials are only sent to same-host sources, and failed cross-zone transforms don't pass origin headers through (mirroring image-resizing-worker)
  • Wired through wrangler dev, getPlatformProxy and the Vite plugin
  • Behavioural change: /cdn-cgi/image/ requests no longer reach the Worker locally unless enabled, matching production
  • Known local differences: only basic transforms are applied, and in the Vite dev server same-host source images are fetched through Vite so public/ files resolve

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: docs will follow once the feature is generally available

@changeset-bot

changeset-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8361f2b

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

This PR includes changesets to release 16 packages
Name Type
miniflare Minor
wrangler Minor
@cloudflare/vite-plugin Minor
@cloudflare/workers-utils Minor
@cloudflare/config Patch
@cloudflare/deploy-helpers Patch
@cloudflare/dev-helpers Patch
@cloudflare/pages-shared Patch
@cloudflare/remote-bindings Patch
@cloudflare/runtime-types Patch
@cloudflare/vitest-plugin Patch
@cloudflare/autoconfig Patch
@cloudflare/build-output-utils Patch
@cloudflare/cli-shared-helpers Patch
@cloudflare/containers-shared 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@16678

@cloudflare/build-output-utils

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

@cloudflare/cli-shared-helpers

npm i https://pkg.pr.new/@cloudflare/cli-shared-helpers@16678

@cloudflare/codemods

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

@cloudflare/config

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

@cloudflare/containers-shared

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

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

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

@cloudflare/pages-shared

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

@cloudflare/runtime-types

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

@cloudflare/test-server

npm i https://pkg.pr.new/@cloudflare/test-server@16678

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-plugin

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 8361f2b

@mglewis
mglewis force-pushed the mattl/IMAGES-2346-cdn-cgi-image-local-transforms branch from d7cd715 to ee4ace8 Compare November 3, 2026 14:40
@mglewis
mglewis force-pushed the mattl/IMAGES-2346-cdn-cgi-image-local-transforms branch 5 times, most recently from 789db43 to 268537a Compare November 6, 2026 17:03
@mglewis
mglewis force-pushed the mattl/IMAGES-2346-cdn-cgi-image-local-transforms branch from 268537a to a415ccf Compare November 16, 2026 15:44
@mglewis mglewis changed the title [miniflare] Add local development support for /cdn-cgi/image/ URL transformations [miniflare] Add local development support for /cdn-cgi/image/ URL transformations [Part 3] Nov 17, 2026
@mglewis
mglewis force-pushed the mattl/IMAGES-2346-cdn-cgi-image-local-transforms branch 6 times, most recently from 7c3fd1e to 2be593f Compare November 19, 2026 16:54
@petebacondarwin
petebacondarwin force-pushed the mattl/IMAGES-2346-cdn-cgi-image-local-transforms branch from 2be593f to 996cc82 Compare November 20, 2026 07:17
@mglewis
mglewis force-pushed the mattl/IMAGES-2346-cdn-cgi-image-local-transforms branch 4 times, most recently from 752f9e9 to ac48682 Compare November 20, 2026 14:37
@mglewis
mglewis marked this pull request as ready for review November 20, 2026 14:47
@workers-devprod
workers-devprod requested review from a team and removed request for a team November 20, 2026 14:47
devin-ai-integration[bot]

This comment was marked as resolved.

@mglewis
mglewis force-pushed the mattl/IMAGES-2346-cdn-cgi-image-local-transforms branch from 6a7e3a2 to 92a6a14 Compare November 24, 2026 14:15
devin-ai-integration[bot]

This comment was marked as resolved.

@petebacondarwin
petebacondarwin requested review from petebacondarwin and removed request for edmundhung November 25, 2026 13:43
@workers-devprod

workers-devprod commented Nov 25, 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.

devin-ai-integration[bot]

This comment was marked as resolved.

@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.

LGTM - although I asked a bunch of questions that I'd like to know the answers to before we merge this.

Comment thread packages/miniflare/src/index.ts Resolved

@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

…lify log-once handling and warn about wildcard origins
@mglewis
mglewis force-pushed the mattl/IMAGES-2346-cdn-cgi-image-local-transforms branch from 18c0119 to 8361f2b Compare November 30, 2026 15:56
@petebacondarwin
petebacondarwin merged commit 7d57524 into cloudflare:main Nov 30, 2026
80 checks passed
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in workers-sdk Nov 30, 2026
brandhaug added a commit to brandhaug/b2b-saas-starter that referenced this pull request Dec 4, 2026
## pnpm-workspace.yaml (default)

## Dependency Updates

| Package | From | To | Type |
| --- | --- | --- | --- |
| `@cloudflare/vitest-plugin` | 1.10.1 | 1.10.2 | patch |
| `miniflare` | 5.20261127.1-beta | 5.20261129.0-beta | minor |
| `wrangler` | 4.169.1 | 4.170.0 | minor |

## Release Notes

<details>
<summary><b>@<!---->cloudflare/vitest-plugin</b> (1.10.1 →
1.10.2)</summary>

### Patch Changes

- [#17284](cloudflare/workers-sdk#17284)
[`5b6e6bf`](cloudflare/workers-sdk@5b6e6bf)
Thanks [@<!---->dependabot](https://github.com/apps/dependabot)! -
Update `DEFAULT_COMPAT_DATE` to 2026-11-29

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

- [#17211](cloudflare/workers-sdk#17211)
[`b91cef9`](cloudflare/workers-sdk@b91cef9)
Thanks [@<!---->jamesopstad](https://github.com/jamesopstad)! - Keep
remote bindings working after a failed change to the account or API
token is reverted

Previously, changing the account ID or API token to credentials that
failed to start a remote session (for example, a malformed account ID)
disposed the existing session first. Reverting the change then reused
that disposed session, so remote bindings stayed offline until the
development server was restarted. The existing session is now disposed
only once its replacement is ready, so it keeps working if the new
credentials fail to start a session.

- [#17244](cloudflare/workers-sdk#17244)
[`a332568`](cloudflare/workers-sdk@a332568)
Thanks [@<!---->dario-piotrowicz](https://github.com/dario-piotrowicz)!
- Explain where misplaced fields belong in `cloudflare.config.ts`
validation errors

Errors for top-level fields such as `accountId` placed under `worker`
now explain that they belong at the top level. Worker fields placed at
the top level also include a hint to move them inside `worker`.

- [#16888](cloudflare/workers-sdk#16888)
[`3d78112`](cloudflare/workers-sdk@3d78112)
Thanks [@<!---->smile-alive](https://github.com/smile-alive)! - Suppress
`Aborting engine` uncaught exceptio

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

</details>

<details>
<summary><b>miniflare</b> (5.20261127.1-beta →
5.20261129.0-beta)</summary>

### Minor Changes

- [#16678](cloudflare/workers-sdk#16678)
[`7d57524`](cloudflare/workers-sdk@7d57524)
Thanks [@<!---->mglewis](https://github.com/mglewis)! - Add local
development support for `/cdn-cgi/image/` URL transformations

When `images.url_transformations` (or `images.urlTransformations` in
`cloudflare.config.ts`) is enabled, Miniflare now handles
`/cdn-cgi/image/<options>/<source>` requests locally before they reach
your Worker. Requests return a 404 when URL transformations aren't
enabled for the Worker, and a 403 when the source image isn't allowed by
`allowed_origins`. Transforms use the same low-fidelity Sharp-backed
mock as `cf.image` fetches, so only resize, rotate, format conversion
and a small set of options are applied.

This is a change in behaviour: previously `/cdn-cgi/image/` requests
were passed through to the Worker during local development.

Requests made through `SELF` in `@cloudflare/vitest-plugin` bypass
Miniflare's routing and are not intercepted.

### Patch Changes

- [#17284](cloudflare/workers-sdk#17284)
[`5b6e6bf`](cloudflare/workers-sdk@5b6e6bf)
Thanks [@<!---->dependabot](https://github.com/apps/dependabot)! -
Update `DEFAULT_COMPAT_DATE` to 2026-11-29

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

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

  The following dependency versions have been updated:

  | Dependency                | From          | To            |
  | ------------------------- | ------------- | ------------- |
  | @<!---->cloudflare/workers-types |

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

</details>

<details>
<summary><b>wrangler</b> (4.169.1 → 4.170.0)</summary>

### Minor Changes

- [#16678](cloudflare/workers-sdk#16678)
[`7d57524`](cloudflare/workers-sdk@7d57524)
Thanks [@<!---->mglewis](https://github.com/mglewis)! - Add local
development support for `/cdn-cgi/image/` URL transformations

When `images.url_transformations` (or `images.urlTransformations` in
`cloudflare.config.ts`) is enabled, Miniflare now handles
`/cdn-cgi/image/<options>/<source>` requests locally before they reach
your Worker. Requests return a 404 when URL transformations aren't
enabled for the Worker, and a 403 when the source image isn't allowed by
`allowed_origins`. Transforms use the same low-fidelity Sharp-backed
mock as `cf.image` fetches, so only resize, rotate, format conversion
and a small set of options are applied.

This is a change in behaviour: previously `/cdn-cgi/image/` requests
were passed through to the Worker during local development.

Requests made through `SELF` in `@cloudflare/vitest-plugin` bypass
Miniflare's routing and are not intercepted.

- [#17266](cloudflare/workers-sdk#17266)
[`b9bb1b0`](cloudflare/workers-sdk@b9bb1b0)
Thanks [@<!---->dependabot](https://github.com/apps/dependabot)! -
Support Analog 3 in `wrangler setup`

Configure Analog’s standalone Nitro Vite plugin for Cloudflare Workers.
Both `wrangler setup` and `create-cloudflare` configure the Minimal
starter as a static site. Analog 2 projects continue to use the Nitro
options on the Analog Vite plugin. Projects using native Nitro 3
(`nitro/vite`) should use Nitro’s generated Wrangler configuration
instead.

### Patch Changes

- [#17258](cloudflare/workers-sdk#17258)
[`e96e508`](cloudflare/workers-sdk@e96e508)
Thanks [@<!---->irvinebroque](https://github.com/irvinebroque)! - Show
the plan-specific Time Travel retention window in `wr

…[full
notes](https://github.com/cloudflare/workers-sdk/releases/tag/wrangler%404.170.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.

4 participants