Skip to content

fix(website): move v2.alchemy.run redirect into the Worker - #836

Closed
sam-goodwin wants to merge 1 commit into
mainfrom
claude/v2-redirect-in-worker
Closed

fix(website): move v2.alchemy.run redirect into the Worker#836
sam-goodwin wants to merge 1 commit into
mainfrom
claude/v2-redirect-in-worker

Conversation

@sam-goodwin

Copy link
Copy Markdown
Contributor

The prod deploy of #806 failed creating the V2Redirect Ruleset — the deploy token has no zone-ruleset permissions:

ERROR: Forbidden: request is not authorized
  at PUT /zones/{zone_id}/rulesets/phases/http_request_dynamic_redirect/entrypoint

Everything else landed: the Worker deployed and both custom domains attached, so alchemy.run is already serving the new site. This PR replaces the Ruleset with a redirect in the Worker itself, which needs no extra token permissions — assets run runWorkerFirst, so the Worker sees every request:

const LEGACY_HOST = "v2.alchemy.run";
const redirectLegacyHost = (request: Request): Response | undefined => {
  const url = new URL(request.url);
  if (url.host !== LEGACY_HOST) return undefined;
  url.host = CANONICAL_HOST;
  return Response.redirect(url.toString(), 301);
};
  • The adopted Zone stays declared (adopt + retain).
  • The failed Ruleset never created anything, so removing it is a state-only cleanup (no delete API call — its state has no attributes).

If the prod token is later re-minted with zone-ruleset permissions, this can move back to a http_request_dynamic_redirect Ruleset so redirects short-circuit at the edge without invoking the Worker.

🤖 Generated with Claude Code

The prod deploy failed creating the http_request_dynamic_redirect
Ruleset: the deploy token has no zone-ruleset permissions
(PUT /zones/{id}/rulesets/phases/.../entrypoint → 403 Forbidden).
The Worker already runs first on every request (runWorkerFirst), so
redirect v2.alchemy.run → alchemy.run there instead — no extra token
permissions needed.

The adopted Zone stays declared (retain). The failed Ruleset never
created, so its removal is a state-only cleanup.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant