Deploying to Cloudflare Workers
Deploy your Astro site to Cloudflare Workers with PhantomStudio.
Deploying to Cloudflare Workers
PhantomStudio deploys to Cloudflare through Workers. This supports server-rendered pages (Dynamic and Dynamic, cached), WooCommerce stores, and API routes.
Connect Cloudflare
- Create a Cloudflare API token with these account permissions: Account Settings: Read, Workers Scripts: Edit and Workers KV Storage: Edit. The connect dialog's Create Token button opens Cloudflare with these filled in. Under Account Resources, include all accounts or the one you want to deploy to.
- Connect it in one of two places:
- Dashboard: in the Connections panel, under Deployments, click Connect next to Cloudflare Workers.
- Editor: open Publish ▾. If no provider is connected yet, click Use Cloudflare instead.
- Paste the token. If it can reach more than one Cloudflare account, also enter the account ID.
- Click Connect Cloudflare.
PhantomStudio stores the account ID with the connection and uses it for Workers API calls.
Deploy a Project
Connecting from the editor deploys the open project right away. From the dashboard, open the project's ⋯ menu and click Deploy to Cloudflare. If Vercel is connected too and the project has never been deployed, Publish ▾ offers Deploy to Vercel and Deploy to Cloudflare Workers: pick one.
The first deployment sets up:
@astrojs/cloudflarewrangler.jsonc- A GitHub Actions workflow that runs
npm run buildandnpx wrangler deploy - GitHub repository secrets for the Cloudflare credentials and deployment environment variables
GitHub Actions must be enabled for the repository.
PhantomStudio commits these setup files to GitHub during the first deployment, so the copy you have open in the editor doesn't include them yet. Your next publish brings them in; if you changed the same files (such as astro.config.mjs or package.json), it walks you through the overlap. See Publishing Changes and Resolving Conflicts. With no unpublished changes, Publish ▾ › Get the latest from GitHub also works, but it replaces your copy with GitHub's, so don't use it while you have unpublished work.
After that, every publish deploys: the workflow runs on each push to the default branch. Drafts on other branches don't deploy. Publish ▾ › Deploy now rebuilds what's on GitHub without new changes, and Publish ▾ › Deploy history lists recent deployments.
Sitemaps
After the first deployment assigns a Workers URL, set it in Site ▾ › SEO Settings, publish the generated changes, and deploy again so Astro can build the sitemap with valid production URLs. See Sitemaps on Cloudflare Workers for the complete workflow, custom domains, imported projects, and verification steps.
Environment Variables
PhantomStudio stores WordPress and WooCommerce environment variables as GitHub Actions secrets when you save Site ▾ › WordPress. Deploy again after changing settings. Publish ▾ › Environment variables is for Vercel only.
Domains
Add a custom domain or route in the Cloudflare Workers dashboard (the project's ⋯ menu on the PhantomStudio dashboard has Cloudflare Dashboard). PhantomStudio's domain dialog supports Vercel domains only.