[wrangler] Extract remote bindings into shared packages#12946
[wrangler] Extract remote bindings into shared packages#12946penalosa wants to merge 1 commit intopenalosa/shared-binding-helpersfrom
Conversation
🦋 Changeset detectedLatest commit: 58119b6 The changes in this PR will be included in the next version bump. 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 |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
|
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
| undefined, | ||
| complianceRegion | ||
| ); | ||
| return result.subdomain; |
There was a problem hiding this comment.
🔴 Missing .workers.dev suffix in remote-bindings subdomain, causing all proxy requests to target wrong host
The new getWorkersDevSubdomain in packages/remote-bindings/src/api/subdomain.ts returns only the raw subdomain from the API (e.g., my-account), but the old wrangler implementation at packages/wrangler/src/routes.ts:32 appends .workers.dev (and a compliance-region subdomain when applicable). This means createPreviewSession at packages/remote-bindings/src/api/preview-session.ts:84 constructs a host like worker-name.my-account instead of the correct worker-name.my-account.workers.dev. The ProxyServer then proxies all HTTP/WebSocket traffic to this incomplete hostname, causing every remote binding request to fail.
Old wrangler code that appends the suffix
// packages/wrangler/src/routes.ts:32
return `${subdomain}${getComplianceRegionSubdomain(complianceConfig)}.workers.dev`;New code that omits it:
// packages/remote-bindings/src/api/subdomain.ts:17
return result.subdomain;Prompt for agents
In packages/remote-bindings/src/api/subdomain.ts, the function getWorkersDevSubdomain must append .workers.dev to the raw subdomain returned by the API. Additionally, it should handle the compliance region subdomain (e.g. for EU regions). The old wrangler code at packages/wrangler/src/routes.ts:32 did: return `${subdomain}${getComplianceRegionSubdomain(complianceConfig)}.workers.dev`. The fix should change line 17 from `return result.subdomain;` to something like `return `${result.subdomain}${complianceRegion === 'eu' ? '.eu' : ''}.workers.dev`;` — verify with the existing getComplianceRegionSubdomain helper to get the exact logic right.
Was this helpful? React with 👍 or 👎 to provide feedback.
38eeda5 to
8705073
Compare
048c516 to
019587c
Compare
Replace the full DevEnv pipeline for remote preview sessions with direct API calls and a minimal Node.js HTTP proxy. Wrangler's programmatic API is preserved via a compatibility wrapper that resolves auth and delegates to the new package.
8705073 to
58119b6
Compare
Extract remote bindings session setup into
@cloudflare/remote-bindings.Stacked on #12948.
@cloudflare/remote-bindings— preview session creation, token exchange, and minimal Node.js HTTP proxy (replaces the full DevEnv pipeline)remoteBindings/index.tsto delegate to the new package with a backward-compatible wrapperreadFileSyncat runtime)