Skip to content

[remote-bindings] Use Worker-scoped preview sessions - #17035

Merged
petebacondarwin merged 3 commits into
mainfrom
codex/worker-scoped-remote-bindings
Nov 19, 2026
Merged

petebacondarwin merged 3 commits into
mainfrom
codex/worker-scoped-remote-bindings

Conversation

@petebacondarwin

@petebacondarwin petebacondarwin commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #16870.

Remote bindings still create sessions through the account-level /accounts/:accountId/workers/subdomain/edge-preview endpoint, preventing tokens scoped to an individual Worker from authenticating that request.

Use /accounts/:accountId/workers/scripts/:name/subdomain/edge-preview and derive the preview hostname from exchange_url, matching the Workers.dev preview flow in wrangler dev --remote (#15476). Preserve the subdomain lookup/registration fallback for responses without a usable exchange URL.

The change lives in the shared remote-bindings package, covering getPlatformProxy, Wrangler, the Vite plugin, and the Vitest integration. Miniflare configuration and the native binding transport, including D1 batch behavior, are unchanged.

Validation:

  • All 49 remote-bindings tests pass, including nine new tests covering public/FedRAMP sessions without account-wide requests, failed token exchange, legacy fallback, and Worker authorization errors.
  • All 27 affected Wrangler tests pass, covering remote binding startup errors, preview sessions, and the remote runtime controller. The error tests now intercept the Worker-scoped session endpoint.
  • Confirmed the new tests fail against the original implementation at the account-level session request.
  • Package build and type check pass; focused lint and formatting checks pass.
  • Live validation with a granular account-owned token remains outstanding.

  • 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: this fixes internal preview-session API usage without changing configuration or public APIs.

Devin Review

@changeset-bot

changeset-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: db07f73

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

This PR includes changesets to release 3 packages
Name Type
wrangler Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-plugin 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

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Nov 19, 2026
@workers-devprod
workers-devprod requested review from a team and edmundhung and removed request for a team November 19, 2026 10:30
@workers-devprod

workers-devprod commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@ask-bonk

ask-bonk Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

devin-ai-integration[bot]

This comment was marked as resolved.

clanky-the-clanker[bot]

This comment was marked as resolved.

@pkg-pr-new

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

Copy link
Copy Markdown
@cloudflare/autoconfig

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

@cloudflare/build-output-utils

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

@cloudflare/codemods

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

@cloudflare/config

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

@cloudflare/containers-shared

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

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

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

@cloudflare/pages-shared

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

@cloudflare/runtime-types

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-plugin

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: db07f73

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

Superseded by the review of db07f73d.

This review, of f77ba926

💬 Approved with comments — The switch to the Worker-scoped preview-session endpoint is correct, keeps the legacy fallback, and is well tested. The one open note is that the changeset overstates what the change avoids.

Findings: 1 suggestion

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


📝 Documentation: 💬 1 suggestion

The changeset overstates avoiding account-wide subdomain access.

Recommendation: 💬 Optional Nits

  • [SUGGESTION] Changeset claim about avoiding account-wide subdomain access does not mention the fallback path. (.changeset/worker-scoped-remote-bindings.md:9)
View full review

.changeset/worker-scoped-remote-bindings.md:9 says the change avoids account-wide Workers subdomain access. When exchange_url is missing or unusable, createPreviewSession still looks up or registers the account subdomain.


✅ All other checks passed

🚀 Release: ✅ LGTM

Overall risk: Medium. The change alters the preview-session API path that development tooling uses.

The changeset has patch bumps for wrangler, @cloudflare/vite-plugin and @cloudflare/vitest-plugin; the unpublished @cloudflare/remote-bindings package is now left out of it. The pull request description notes that live validation with a granular account-owned token is still outstanding.


🔒 Security: ✅ LGTM

No security concerns. In the common case the change needs narrower API permissions than before.


📖 AGENTS.md: ✅ LGTM

The change follows the repository conventions.


📋 Code Quality: ✅ LGTM

Session creation uses the Worker-scoped endpoint and derives the preview host from exchange_url. The legacy subdomain fallback is kept, and the tests cover the success, fallback and error paths.


⚡ Performance: ✅ LGTM

The account subdomain lookup now runs only as a fallback, so the common path makes one fewer API call per session.


Reviewed commit: f77ba926

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

✅ Approved — The switch to the Worker-scoped preview-session endpoint is correct, keeps the legacy subdomain fallback, and is well tested. The changeset now describes the fallback path accurately, which resolves the earlier note.

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


✅ All checks passed

🚀 Release: ✅ LGTM

Overall risk: Medium. The change alters the preview-session API path that remote bindings use.

  • The changeset bumps wrangler, @cloudflare/vite-plugin and @cloudflare/vitest-plugin as patches.
  • The unpublished @cloudflare/remote-bindings package is left out of the changeset.
  • The pull request description says live validation with a granular account-owned token is still outstanding.

🔒 Security: ✅ LGTM

This adds no new injection, authorization or credential-exposure risk.

  • The Worker name comes from the user's own config.
  • Requests are authenticated with the user's own token.
  • In the common case the change needs narrower API permissions than before.

📖 AGENTS.md: ✅ LGTM

The change follows the repository's conventions.


📋 Code Quality: ✅ LGTM

Remote bindings now create sessions through the Worker-scoped endpoint, and the preview host is built from exchange_url.

  • If the exchange URL is missing, invalid or has no dot in its hostname, getWorkersDevPreviewHost returns undefined and the code falls back to the account subdomain.
  • The new tests cover public and FedRAMP sessions, a failed token exchange, unusable exchange URLs, subdomain registration and a 403 error.
  • The Wrangler error-test mocks now intercept the new endpoint path.

⚡ Performance: ✅ LGTM

The account subdomain lookup now runs only as a fallback, so the common path makes one fewer API call per session.


📝 Documentation: ✅ LGTM

The changeset now says the account subdomain lookup or registration is still used when the response has no usable exchange URL. This resolves the earlier note.


Reviewed commit: db07f73d

@edmundhung edmundhung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice!

@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 Untriaged to Approved in workers-sdk Nov 19, 2026
@petebacondarwin
petebacondarwin merged commit 1b563db into main Nov 19, 2026
88 of 90 checks passed
@petebacondarwin
petebacondarwin deleted the codex/worker-scoped-remote-bindings branch November 19, 2026 14:26
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Nov 19, 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.

getPlatformProxy remote D1: account preview-session endpoint returns 10000 with granular account-owned token

3 participants