Branch Deployments
View and test Cloudflare Pages preview deployments for feature branches with admin access bypass
Branch Deployments
The Deployments page at /admin/deployments shows all recent Cloudflare Pages deployments — both preview (branch) and production. Its main purpose is letting you test feature branch previews with full admin access before merging.
The Problem It Solves
When Claw or any contributor pushes a feature branch, Cloudflare Pages automatically builds and deploys a preview at <branch>.Arcturus-Prime.pages.dev. However, the Arcturus-Prime middleware blocks /admin/* routes on non-Arcturus-Prime.com hosts and redirects all *.pages.dev traffic to Arcturus-Prime.com.
The middleware has a ?preview parameter bypass: adding ?preview to any pages.dev URL sets a sticky cookie (__argobox_preview=1, 24-hour TTL) that:
- Skips the
*.pages.dev→Arcturus-Prime.comredirect - Allows
/admin/*routes to render on the preview domain - Persists across subsequent page navigations without needing
?previewagain
The Deployments page generates preview links with ?preview already appended, so you can click straight through to test admin pages on any branch preview.
Page Layout
Stats Row
Three stat cards at the top:
- Preview — count of preview deployments in the current result set
- Production — count of production deployments
- Branches — unique branch count across preview deploys
Filter Bar
- Toggle buttons — All / Preview / Production. Filters the deployment list by environment.
- Search box — Filters by branch name (case-insensitive substring match). Works in combination with the environment filter.
Deployment List
Full-width cards sorted newest-first. Each card shows:
- Status dot — green (success), red (failure), yellow (building), gray (canceled)
- Environment badge — blue pill for preview, green pill for production
- Branch name — bold, primary identifier
- Time ago — relative time since deployment
- Commit message — truncated with ellipsis
- Commit hash — short 7-char hash in orange monospace
- Action buttons — contextual based on environment and status
Action Buttons
| Environment | Status | Button |
|---|---|---|
| Preview | Success | Open Preview — opens <url>?preview in new tab |
| Production | Success | Open Site — opens production URL |
| Any | Failure | ”Build failed” label (no link) |
| Any | Active | ”Building…” label with pulse animation |
Auto-Refresh
The deployment list refreshes automatically every 60 seconds. Manual refresh via the button in the header.
API
Reuses the existing /api/dashboard/cf-pages endpoint with an increased limit parameter:
GET /api/dashboard/cf-pages?project=Arcturus-Prime&limit=30
The limit parameter (default 5, max 50) controls how many deployments are returned. The endpoint fetches from the Cloudflare API at:
https://api.cloudflare.com/client/v4/accounts/{CF_ACCOUNT_ID}/pages/projects/Arcturus-Prime/deployments
Required env vars: CF_API_TOKEN, CF_ACCOUNT_ID
Module Registration
Registered as the deployments module in src/config/modules/deployments.ts:
Module ID: deployments
Nav Item: Deployments (group: dev)
Icon: fa-rocket
Pages: /admin/deployments
API Routes: /api/dashboard/cf-pages
Required Env: CF_API_TOKEN, CF_ACCOUNT_ID
Preview Cookie Mechanics
The ?preview bypass is implemented in src/middleware.ts:
- First visit with
?previewon a*.pages.devdomain - Middleware strips the param from the URL
- Sets cookie:
__argobox_preview=1; Path=/; SameSite=Lax; Secure; Max-Age=86400 - Redirects (302) to the clean URL
- All subsequent requests on that domain check the cookie and skip both the redirect and the admin route block
The cookie expires after 24 hours. To revoke access early, clear the __argobox_preview cookie.
Workflow: Testing Claw’s Changes
- Claw pushes a feature branch to Gitea
- Gitea mirrors to GitHub (via push mirror)
- Cloudflare Pages auto-builds and deploys a preview
- Go to
/admin/deployments— new preview appears in the list - Click Open Preview — opens the branch preview with admin access
- Test the changes (including admin pages)
- Go to
/admin/pull-requests— merge or close the PR - Click Sync to GitHub if needed