Repository navigation
[vite-plugin] Use cf credentials for remote bindings - #16428
edmundhung wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: 9b2f41c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
LGTM! |
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
Remote bindings fell back to Wrangler's credentials unless Vite was started by `cf dev`. Pass a cf auth hook, resolved from the project root, to the dev and preview remote proxy sessions, and seed a cf profile in the directory-bound profile e2e test. DEVX-2646
bbfcf2d to
273f002
Compare
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
|
💬 Approved with comments — The change does what it claims: remote bindings use cf credentials in both Findings: 1 info The decision is advisory: this comment never approves, blocks or requests changes on the pull request. 🔧 Fix with your agentPaste the following into your coding agent to investigate and fix these issues. 📋 Code Quality: 💬 1 infoThe change is sound. One note: the cached auth hook keeps the logger from the first Vite server. Recommendation: 💬 Optional Nits
View full review
These checks found no problems:
✅ All other checks passed🔒 Security: ✅ LGTMNo security concerns. Credentials are resolved through the existing cf auth flow, keyed by project root and account ID. 📖 AGENTS.md: ✅ LGTMNo AGENTS.md updates needed. ⚡ Performance: ✅ LGTMNo performance concerns. Credentials are resolved only when a session first needs them. 📝 Documentation: ✅ LGTMThe changeset describes the credential change, and the new function has JSDoc. Reviewed commit: |
Fixes DEVX-2646.
Remote bindings in the v2 Vite plugin should use cf credentials, but they only did when Vite was started by
cf dev.@cloudflare/remote-bindingspicks the cf credential store only whenCLOUDFLARE_CF_AUTHis set, and onlycf devsets it. So runningvite devorvite previewdirectly used Wrangler's credentials.The plugin now passes its own cf auth hook to
maybeStartOrUpdateRemoteProxySession()for both dev and preview. The hook resolves the cf profile from the project root and forwards the configured account ID. It reuses the plugin's existing cf auth setup (already used for tunnels).@cloudflare/remote-bindingsis unchanged.Hooks are cached per project root and account ID.
maybeStartOrUpdateRemoteProxySession()restarts the session whenever it receives a different hook, and the plugin recomputes its Miniflare options several times per server (start, export type changes, restarts). Credentials are only resolved when a session first needs them.The directory-bound profile e2e test now seeds a cf profile instead of a Wrangler one.
The Vitest plugin counterpart is #16424: its
cloudflare.config.tspath gets the same cf auth hook. This PR should merge first.