[workers-playground] Migrate from Cloudflare Pages to Cloudflare Workers#12655
Merged
petebacondarwin merged 8 commits intomainfrom Mar 11, 2026
Merged
[workers-playground] Migrate from Cloudflare Pages to Cloudflare Workers#12655petebacondarwin merged 8 commits intomainfrom
petebacondarwin merged 8 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 9696173 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
73d8406 to
b9123a5
Compare
06d9f73 to
fed7889
Compare
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
Contributor
|
✅ All changesets look good |
bba9827 to
581bc9d
Compare
c58edec to
1f5b82b
Compare
Contributor
|
Workers Playground preview: https://02629ffa-workers-playground.devprod.workers.dev/playground |
6e11af7 to
90bd855
Compare
Contributor
Author
|
Blocked on #12791 |
90bd855 to
3cdf89c
Compare
3cdf89c to
ef6543a
Compare
b5d52ef to
af64326
Compare
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers |
emily-shen
approved these changes
Mar 10, 2026
09a2996 to
c6a21fc
Compare
penalosa
reviewed
Mar 10, 2026
penalosa
approved these changes
Mar 10, 2026
c6a21fc to
3cf6189
Compare
…rs domain support - Add subdomain boundary check (dot prefix) to pages.dev referer validation to prevent spoofed hostnames like evil-workers-playground.pages.dev from bypassing the allowlist - Add .workers.dev hostnames to the referer allowlist (needed for the upcoming migration from Pages to Workers deployments) - Replace hardcoded tokens in test snapshots with dynamic template literals and convert toMatchInlineSnapshot() to toEqual() for deterministic assertions - Add test cases for spoofed pages.dev and workers.dev hostnames
Replace the Cloudflare Pages deployment with a Workers + static assets deployment. In production, the Worker is assets-only (no server-side code entry point). For local development, a dev-only Worker entry point replicates the proxying behavior of the production playground-preview-worker. Production deployment: - Add wrangler.jsonc (assets-only) and wrangler.dev.jsonc (with worker) - Replace 'wrangler pages deploy' with 'wrangler deploy' - Remove Pages Functions (functions/ directory) Local development: - Add src/worker.ts that proxies /playground/api/* to the testing backend and injects an auth cookie on /playground - Use @cloudflare/vite-plugin instead of Vite's built-in proxy Other changes: - Rename deploy-pages-previews.yml to deploy-previews.yml - Rename defaultHashes.ts to defaultHashes.js (generated file) - Rename requirements.txt to cf-requirements.txt (Python convention) - Replace tsx with esbuild-register for running generate script - Update README, CONTRIBUTING.md, and CI workflow
The workers-playground can now be run locally with full functionality via `pnpm dev -F @cloudflare/workers-playground`, which starts the Vite dev server with a proxy worker that forwards API calls to the testing playground-preview-worker. This makes PR preview deployments unnecessary. Additionally, the deployed previews never actually worked properly because they were deployed as standalone static asset Workers without the playground-preview-worker proxy in front of them, making the playground non-functional in preview environments. - Remove preview script from workers-playground package.json - Remove preview turbo task and VITE_DEVTOOLS_PREVIEW_URL env var - Remove all workers-playground steps from deploy-previews.yml - Remove preview:workers-playground from workflow trigger condition - Update documentation in README, CONTRIBUTING.md, and chrome-devtools-patches README to remove preview label references
…into global turbo config Move CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN from per-package turbo.json passThroughEnv declarations into the root turbo.json globalPassThroughEnv. These env vars are needed by multiple packages for deployment and testing, and duplicating them across 8 separate turbo configs is unnecessary.
…ackage is never deployed
…TURBO_EXTENDS$ Move CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_API_TOKEN, and NODE_DEBUG into the root test:e2e task env (cache-key-affecting) so credential changes bust the E2E test cache. Per-package test:e2e overrides now use $TURBO_EXTENDS$ to inherit from root instead of duplicating entries. Also restore CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN to vitest-pool-workers test task env for remote-proxy-cleanup.test.ts.
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
3cf6189 to
9696173
Compare
Merged
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.
Fixes #[N/A — internal infrastructure change].
Migrate
workers-playgroundfrom a Cloudflare Pages deployment to a Cloudflare Workers deployment with static assets.Summary
Production deployment
wrangler pages deploy) with a Workers + static assets deployment (wrangler deploy)wrangler.jsonc), this is an assets-only Worker with no code entry point — theplayground-preview-workerhandles all routing and proxying in front of itwrangler.jsoncandwrangler.dev.jsoncconfigs; remove the Pages Functions fromfunctions/Local development
@cloudflare/vite-plugininstead of Vite's built-in proxy, so the full Worker stack runs locally viapnpm devsrc/worker.ts) that replicates the proxying behavior of the productionplayground-preview-worker: proxies/playground/api/*to the testing backend, and injects an auth cookie on/playgroundso the preview iframe can authenticatefunctions/playground/[[route]].tsandfunctions/playground/api/[[route]].ts) with this new WorkerPreview deployment removal
previewscript and turbo task — PR preview deployments of workers-playground never worked properly because the deployed preview was a standalone static asset Worker with noplayground-preview-workerproxy in front of it, so the playground was non-functional in preview environments.github/workflows/deploy-previews.ymlpnpm dev, there is no need for deployed previews to test changesOther changes
playground-preview-workerreferer allowlist to also accept*.workers-playground.workers.dev(in addition to*.workers-playground.pages.dev).endsWith()for subdomains (prevents spoofing via e.g.evil-workers-playground.pages.dev)CLOUDFLARE_ACCOUNT_IDandCLOUDFLARE_API_TOKENintoglobalPassThroughEnvin rootturbo.jsoninstead of duplicating across per-package turbo configsdefaultHashes.tstodefaultHashes.js(it's a generated file with no TypeScript)requirements.txttocf-requirements.txtto match the Python Workers conventiontsxwithesbuild-registerfor runninggenerate-default-hashes.tstoEqual()in playground-preview-worker tests for stability