Repository navigation
feat(cloudflare): Worker.URL — bind a Worker's own URL onto itself - #964
Merged
Merged
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Install the packages built from this commit: alchemy bun add alchemy@https://pkg.ing/alchemy/c4e71d4@alchemy.run/better-auth bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/c4e71d4@alchemy.run/pr-package bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/c4e71d4 |
…ted tag The bare-yield/env ergonomics come free from the existing Binding value machinery — no Symbol.iterator overrides, no IIFE. isSelfUrl is structural (kind only) because the engine strips binding-value methods when resolving props for providers. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…e or layer Follows the WorkerLoader pattern: a real Effect carrying the ~alchemy/Kind marker, yieldable in effectful workers (no Effect.provide needed) and declarable on env. Defined inside Worker.ts — a separate URL.ts module forms a value cycle with Worker.ts that the deploy bundler's scope hoisting turns into a script-startup crash (verified: same code inlined works, module split 1101s in cloud while local dev's entry tolerates it). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sam-goodwin
added a commit
that referenced
this pull request
Jul 28, 2026
Resolves Worker.ts / WorkerProvider.ts conflicts (Worker.URL #964 landed alongside the version prop) and rejects Worker.URL bindings on version workers — a version's URL is its preview URL, which only exists after upload. Distilled submodule resolves to main's pointer, which already contains distilled#389. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
john-royal
added a commit
that referenced
this pull request
Jul 30, 2026
Brings in 94 commits from main (local vs live provider modes #963, workersDev/domain props #977, Worker.URL self-binding #964, assets-only Workers #969, Prisma provider #416, version affinity #985, telemetry #860) while preserving this branch's SourceProvider architecture and Website framework integrations. - Worker providers take main's side wholesale; the SourceProvider integration is re-grafted as a dispatch: `props.source` routes through `resolveSource`/`loadSource` (build, hash slots, and local dev in both server and bundle modes via the make-before-break serve path), while script/vite/python/prebuilt/assets-only workers keep main's paths. - Apply.ts: both sides landed the resolved-bindings persistence fix (#874 / ef08f4c); merged as the union, keeping `providerMode` and `bindings` on replaced-state commits. - test Utils/Http.ts: keep main's generalized retryResponse machinery (expectUrlRedirect/expectUrlHeader) and re-add expectDirectStatus on top of it. - Website tests track main's API: `url`/`subdomain` props fold into `workersDev`; dev-mode R2 cleanup skips virtual `dev:` buckets. - cloudflare-tools submodule bumped to this branch's merge of its own upstream main (59c3861); distilled synced to main's pointer. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #953.
Worker.URLinjects a Worker's own public URL as a binding on that same Worker. It works in both Worker styles and underalchemy dev(where it resolves to the local dev-server URL).Effect-native:
Async Workers declare it on
env(InferEnvmaps it tostring), and the canonical Vite case inlines it into the client bundle at build time:How it works:
domain, elsehttps://{name}.{accountSubdomain}.workers.dev), so there is no circularity — the binding emits an alchemy-only{ type: "self_url", name }sentinel that the provider resolves and lowers into aplain_textbinding just beforeputScript, and substitutes into the Vitedefineenv before the build.url: falsewith no domains) and dispatch-namespace user workers.LocalWorkerProviderlowers the sentinel to the dev-proxy URL (Text binding + Vite devdefine).Live tests (
test/Cloudflare/Workers/URL.test.ts, all passing): effectfulyield* Worker.URL, asyncenv: { PUBLIC_URL: Worker.URL }, and a Vite fixture asserting both the build-time inline and the runtime binding equalworker.url.Docs: new
@sectionon the Worker typedoc,## The Worker's own URLin the Workers guide,### The site's own URLin the Vite guide, and a note in the Vite SPA guide's URL-injection section.🤖 Generated with Claude Code