Skip to content

preview-cloudflare: deploy-url assumes the project's pages.dev address is its name #216

Closed

Description

@quantecon-services

Found while fact-checking the preview chapters of the user manual (#190, #213).

What happens

preview-cloudflare builds its preview URL from the project-name input (preview-cloudflare/action.yml:191):

DEPLOY_URL="https://${BRANCH_ALIAS}.${PROJECT_NAME}.pages.dev"

That is right only when the project is served at <project-name>.pages.dev. A Pages project's address is a separate field, its subdomain. wrangler 4.139.0, the pinned version, prints it when it creates a project: It will be available at https://${subdomain}/ (wrangler-dist/cli.js:299684). Cloudflare gives a project another address when its name is already taken on pages.dev, by adding a suffix. Then deploy-url, the comment's preview URL and every lecture link point at the wrong host, possibly at someone else's site.

deployment-url is not affected: it is read from wrangler's output.

Why it is built, not read

#14 made the URL constructed on purpose: the branch alias is stable across pushes, and building it needs no parsing of wrangler's output. That reasoning holds when the subdomain equals the name.

Options

  1. Read the alias from wrangler's output. After a successful deploy, wrangler prints ✨ Deployment alias URL: <alias>, taken from the deployment's own aliases (cli.js:300222-300232). It is the right host in every case, but it brings back the parsing preview-cloudflare: Use branch alias URL instead of hash URL in PR comments #14 removed, and wrangler omits the line when its status call fails.
  2. Look up the project's subdomain before deploying, with wrangler pages project list, or the API's GET /accounts/<account>/pages/projects/<name>, and build the URL from that. The URL stays constructed, at the cost of one more call with the same token.
  3. An optional subdomain input, defaulting to project-name. It needs no new call, but a wrong value fails silently, as today.

Option 2 keeps #14's design and fixes the case.

Until then, the manual's preview-cloudflare chapter (#213) tells readers to check that their project is served at exactly https://<project-name>.pages.dev, and links here.

Activity

  1. added a commit that references this issue on Nov 6, 2026
  2. mmcky commented on Nov 7, 2026

    @mmcky
    Contributor

    Checked against main at e40924a (v0.16.0), with wrangler 4.156.1, the pinned version. The problem is as described, and the URL is still built from project-name (preview-cloudflare/action.yml:285; the placeholder builds it the same way in scripts/preview-comment.cjs:30). It reaches no caller today: the one caller outside this repository, the canary's qe-preview-canary, is served at its own name, as wrangler's alias line in the v0.16.0 canary run shows. Cloudflare's docs don't say when a project gets a subdomain other than its name, but the API keeps subdomain apart from name, so the two can differ, and then every link in the comment points at the wrong host.

    Since this was written, a simpler fix than option 2 has turned up. With WRANGLER_OUTPUT_FILE_PATH set, wrangler 4.156.1 writes a pages-deploy-detailed record after every successful deploy. Its url is the deployment's own URL, https://<hash>.<subdomain>, and it is there even when wrangler's status polls time out and it prints no alias. Cloudflare's own wrangler-action reads that record for its outputs. Taking the subdomain from it keeps #14's design (the alias URL is still built, and stable across pushes) with no extra API call and no new input. Option 2's lookup would work with the same token, since wrangler itself reads the project twice on every deploy, but it would add a token-bearing call and a failure point for the same answer.

    The plan: the deploy step reads the record, checks the URL against a strict https://<label>.<subdomain>.pages.dev pattern, and builds deploy-url as https://<branch>.<subdomain>, with deployment-url from the same record. When the record names no such URL, it warns and falls back to today's <project-name>.pages.dev. When the subdomain differs from the name, it prints a notice. The placeholder keeps <project-name>.pages.dev: its job holds no Cloudflare secret by design, and the deploy's comment replaces it within minutes. A new harness job runs the deploy step against a stub wrangler, including a project served at harness-x7k.pages.dev, which today's code gets wrong. The release canary checks that the real wrangler's record gives qe-preview-canary the same URLs as now. It ships under Fixed in v0.17.0, with no breaking change.

    The maintainer's decisions, 2026-11-07: the fix takes the subdomain from wrangler's pages-deploy-detailed record (a fourth option, in place of option 2's lookup). When the record names no URL of the expected shape, the step warns and falls back to today's <project-name>.pages.dev, with deployment-url empty. The placeholder does no lookup: the chapter says so, and the deploy prints a notice when the subdomain differs from the name. The CHANGELOG entry is Fixed, with no ⚠️ marker.

    Claude Code (on behalf of mmcky), organiser session; the check by the mini:actions-cloudflare session

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is wrong or broken

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions