Skip to content

feat(cloudflare/Worker): add Zone Routes - #438

Merged
sam-goodwin merged 6 commits into
alchemy-run:mainfrom
utopyin:feat/cloudflare-worker-routes
Jul 8, 2026
Merged

feat(cloudflare/Worker): add Zone Routes#438
sam-goodwin merged 6 commits into
alchemy-run:mainfrom
utopyin:feat/cloudflare-worker-routes

Conversation

@utopyin

@utopyin utopyin commented May 26, 2026

Copy link
Copy Markdown
Contributor

Add Wrangler-style zone routes to Cloudflare.Worker via a new routes prop.

yield* Cloudflare.Worker("Api", {
  main: import.meta.filename,
  routes: [
    { pattern: "api.example.com/*", zoneName: "example.com" },
    { pattern: "example.com/api/*", zoneId: "<YOUR_ZONE_ID>" },
  ],
});

Each entry accepts zoneName / zoneId (Wrangler equivalents) or zone (ZoneReference). When the zone is omitted, it is inferred from the pattern hostname. Routes are reconciled on deploy, returned as routes on the worker output, and cleaned up on destroy.

@utopyin
utopyin force-pushed the feat/cloudflare-worker-routes branch from ba92c66 to a305c73 Compare May 26, 2026 11:21
@utopyin
utopyin marked this pull request as draft May 26, 2026 11:24
@utopyin
utopyin force-pushed the feat/cloudflare-worker-routes branch from 58a3b95 to 42dc4bc Compare May 26, 2026 11:27
@utopyin utopyin changed the title feat(cloudflare/worker): add zone routes prop feat(cloudflare/Worker): add zone routes prop May 26, 2026
@utopyin
utopyin force-pushed the feat/cloudflare-worker-routes branch from 42dc4bc to f7b92f0 Compare June 8, 2026 18:16
@utopyin
utopyin force-pushed the feat/cloudflare-worker-routes branch from f7b92f0 to 2346c35 Compare June 8, 2026 18:17
@utopyin

utopyin commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@Mkassabov I see that recent commits have added the Cloudflare.WorkerRoute resource.
Do we still want to support this API?

yield* Cloudflare.Worker("Api", {
  main: import.meta.filename,
  routes: [
    { pattern: "api.example.com/*", zoneName: "example.com" },
    { pattern: "example.com/api/*", zoneId: "<YOUR_ZONE_ID>" },
  ],
});

@sam-goodwin

Copy link
Copy Markdown
Contributor

@claude please merge main into this PR and resolve merge conflicts

sam-goodwin and others added 3 commits July 7, 2026 22:48
Resolve conflicts by taking main's structure (provider moved to
WorkerProvider.ts) and porting the PR's inline zone-routes
reconciliation into it. Rename WorkerRouteProps -> WorkerRouteConfig
to avoid colliding with the standalone Workers Route resource.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- no-op redeploy keeps the same route id
- pattern change (delete+create) + added route with inferred zone
- explicit zoneId, zoneName, and inference spellings
- removal via omitting the routes prop
- out-of-band drift removal with observed state as baseline
- destroy detaches routes from the zone
- refusal to steal a pattern attached to another Worker

Also fix LocalWorkerProvider precreate attrs (routes: []) and the
CloudflareEnvironment double-yield idiom.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Workers routes only serve on proxied hostnames; the standing test zone
lost its apex record (and universal cert) to a nuke. Ensure a proxied
AAAA 100:: placeholder exists out-of-band before the HTTP assertions,
and fix the conflict-test assertion to compare physical worker names.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sam-goodwin sam-goodwin changed the title feat(cloudflare/Worker): add zone routes prop feat(cloudflare/Worker): add Zone Routes Jul 8, 2026
@sam-goodwin
sam-goodwin marked this pull request as ready for review July 8, 2026 06:12
sam-goodwin and others added 2 commits July 7, 2026 23:17
Probed live: creating a route for a not-yet-propagated script rejects
with code 10019, now typed as WorkerNotFound via distilled patch
(alchemy-run/distilled#368). Drop the speculative InternalServerError /
UnknownCloudflareError retry.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…tFound tag

Scoped tag instead of widening the shared WorkerNotFound matchers
(alchemy-run/distilled#368).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sam-goodwin
sam-goodwin merged commit dc8717c into alchemy-run:main Jul 8, 2026
8 checks passed
@utopyin

utopyin commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

thank you for taking care of this @sam-goodwin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants