Skip to content

build(web): Workers Static Assets, because Cloudflare stopped offering Pages projects - #332

Merged
rainmanjam merged 2 commits into
mainfrom
feat/workers-static-assets
Aug 14, 2026
Merged

build(web): Workers Static Assets, because Cloudflare stopped offering Pages projects#332
rainmanjam merged 2 commits into
mainfrom
feat/workers-static-assets

Conversation

@rainmanjam

Copy link
Copy Markdown
Owner

wrangler pages deploy refused with The Pages project "polyemesis" does not exist, and Cloudflare no longer offers a way to create one — its dashboard create flow builds a Worker, and the "Upload your static files" option there is Workers Static Assets.

So this is not Pages-versus-Workers on merit. One of the two can still be created.

The migration is small because the hard part does not exist here. Pages Functions are what make this painful, and astro.config.mjs sets output: "static" — no functions/, no _worker.js, no _routes.json, no middleware.

- pages_build_output_dir = "./dist"
+ compatibility_date = "2026-08-13"
+ [assets]
+ directory = "./dist"
+ not_found_handling = "404-page"

not_found_handling is not decoration: a static site's 404 is a page, Astro emits 404.html, and the default answers an unknown path with an empty body.

One guard detail worth reading. It identified the publish step by strings.Contains(s.Run, "pages deploy"). The new run block still contains that string — inside a comment explaining why it no longer uses it. A loose match would have found the comment, called it the publish step, and passed. It now matches the full command.

Verified: wrangler deploy --dry-run reads 27 files from web/dist. Both guard halves mutation-proven — deleting the publish command, and pointing assets.directory at a directory the build does not produce.

…g Pages projects

`wrangler pages deploy` refused with

    ✘ [ERROR] The Pages project "polyemesis" does not exist.

and there is no longer a supported way to create one. Cloudflare's dashboard
"create" flow builds a Worker; its "Upload your static files" option there is
Workers Static Assets, not Pages. So the choice was not Pages-versus-Workers on
merit -- one of the two can still be created.

The migration is small because the hard part does not exist here. Pages
Functions are what make this migration painful, and astro.config.mjs sets
output: "static": no functions/ directory, no _worker.js, no _routes.json, no
middleware, no routing file to reconcile.

  pages_build_output_dir = "./dist"   ->   [assets]
                                           directory = "./dist"

plus a pinned compatibility_date, which a Worker requires and a Pages project
does not. Pinned rather than floating: it is the runtime contract, and one that
moved on its own would change behaviour with no commit to point at.

`not_found_handling = "404-page"` is new and is not decoration -- a static
site's 404 is a page, Astro emits 404.html, and the default would answer an
unknown path with an empty body. Verified web/dist/404.html exists.

THE GUARD MOVED WITH IT, and one detail of that is worth reading. It identified
the publish step by `strings.Contains(s.Run, "pages deploy")`. The new run block
still CONTAINS that string, inside a comment explaining why it no longer uses
it -- so a loose match would find the comment, call it the publish step, and
pass. It now matches the full command.

Verified: `wrangler deploy --dry-run` reads 27 files from web/dist. Both halves
of the guard proven able to fail -- deleting the publish command, and pointing
assets.directory at a directory the build does not produce.

Nothing about the site changes. Same files, same output directory, same
credential gate, same refusal to publish from a pull request.
Copilot AI lite review requested due to automatic review settings August 14, 2026 01:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the web deploy configuration from Cloudflare Pages to Cloudflare Workers Static Assets after Pages project creation is no longer available, while preserving guardrails that ensure the workflow deploys the same directory the build produces.

Changes:

  • Switch wrangler.toml from pages_build_output_dir to Workers Static Assets [assets] configuration and add a pinned compatibility_date.
  • Update the GitHub Actions publish step from wrangler pages deploy to wrangler deploy.
  • Update the deploy-guard test to find the new assets directory field and to identify the publish step by the full command.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
web/wrangler.toml Move from Pages output-dir config to Workers Static Assets config and pin compatibility_date.
internal/testenv/pagesdeploy_test.go Update guards to parse [assets].directory and to detect the new publish command reliably.
.github/workflows/pages.yml Swap the publish command from Pages deploy to Workers deploy while keeping the gate behavior.
Suppressed comments (1)

web/wrangler.toml:33

  • The comment block still claims there should be no compatibility_date because “a runtime does not exist”, but this PR now adds compatibility_date for Workers Static Assets. This is contradictory and will mislead future edits/debugging; update the comment to reflect the current Workers configuration and rationale (no bindings, but compatibility_date required).
# NO compatibility_date, and no bindings. Those configure Pages *Functions*, and
# this site has none: astro.config.mjs sets output: "static", so a deploy is an
# upload of files and nothing runs per request. Adding a date here would suggest
# a runtime that does not exist.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread web/wrangler.toml
Comment on lines +14 to +18
# WORKERS, NOT PAGES, AND NOT BY PREFERENCE. Cloudflare no longer offers Pages
# project creation in its dashboard -- the "create" flow builds a Worker, and
# "Upload your static files" there is Workers Static Assets. `wrangler pages
# deploy` refused with `The Pages project "polyemesis" does not exist` and there
# was no supported way to create one by hand.
Comment on lines +129 to +133
# `wrangler deploy`, not `wrangler pages deploy`. Cloudflare no longer
# offers Pages project creation in its dashboard -- its create flow
# builds a Worker -- and `pages deploy` refused with `The Pages project
# "polyemesis" does not exist` with no supported way to make one. See
# the header of web/wrangler.toml.
Comment on lines +112 to +115
// The Workers form. This read `pages_build_output_dir` until Cloudflare stopped
// offering Pages project creation; the field it replaces served the identical
// purpose, so the assertions below are unchanged in substance.
var pagesOutputDirRE = regexp.MustCompile(`(?ms)^\s*\[assets\].*?^\s*directory\s*=\s*"([^"]+)"`)
…was wrong

Two corrections after reading Cloudflare's Astro and static-asset routing
guides, which I should have read before writing the migration rather than after.

HTML_HANDLING. Cloudflare defaults to `auto-trailing-slash`, which answers
/features with a redirect to /features/. astro.config.mjs sets
`build: { format: "file" }` and `trailingSlash: "never"` precisely to avoid
that, and says so: directory output "costs every internal navigation an extra
round trip for nothing". Taking the default would have reinstated, on every
page, the redirect the site is configured to avoid -- and the site would have
worked, so nothing would have reported it. Pinned to `drop-trailing-slash`.

THE OBSERVABILITY CLAIM WAS WRONG. The PR body cited Workers Logs and Logpush
as a gain over Pages. That comes from a general Pages-versus-Workers comparison
and does not apply here: this Worker has no `main`, so no code runs, and
Cloudflare's own routing doc says navigation requests to a static asset do not
invoke the Worker script at all. There is nothing to log. `[observability]`
would have been configuration that reads as a feature and does nothing, so it
is not being added and the claim is withdrawn instead.

Also confirmed rather than assumed: `_headers` IS honoured by Workers static
assets, same file, same location, so web/public/_headers carries over
unchanged. Its comment named Pages and now names what actually reads it.

The rest of the config is unchanged and matches Cloudflare's documented static
Astro path exactly -- no `main`, no @astrojs/cloudflare adapter, which their
guide states outright is not needed when Astro is used as a static site
generator.

Verified again after the change: build clean, 6 pages, `wrangler deploy
--dry-run` reads 27 files, deploy guard passes.
@sonarqubecloud

Copy link
Copy Markdown

@rainmanjam
rainmanjam merged commit 1fed39d into main Aug 14, 2026
28 checks passed
@rainmanjam
rainmanjam deleted the feat/workers-static-assets branch August 14, 2026 02:09
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.

2 participants