Skip to content

Evaluate CloudFlare Pages deployment feasibility#5

Open
jason-curtis wants to merge 8 commits intomainfrom
claude/github-pages-deployment-feasibility-011CUzsQf75YqhngZn4rF4xN
Open

Evaluate CloudFlare Pages deployment feasibility#5
jason-curtis wants to merge 8 commits intomainfrom
claude/github-pages-deployment-feasibility-011CUzsQf75YqhngZn4rF4xN

Conversation

@jason-curtis
Copy link
Contributor

@jason-curtis jason-curtis commented Nov 10, 2025

Note

Adds Cloudflare Pages deployment using OpenNext with a GitHub Actions workflow, Wrangler config, build scripts, caching headers, and documentation.

  • CI/Deployment:
    • Add GitHub Actions workflow /.github/workflows/deploy-cloudflare-pages.yml with credential checks, API verification, and pages:deploy step.
  • Build/Runtime Config:
    • Introduce OpenNext Cloudflare config (open-next.config.ts) and Wrangler config (wrangler.jsonc).
    • Add deploy scripts and helper: pages:* npm scripts and scripts/prepare-cloudflare-git-deploy.sh.
    • Add static caching headers in public/_headers.
  • Dependencies:
    • Install @opennextjs/cloudflare and wrangler; update package.json scripts.
  • Docs:
    • Add detailed CLOUDFLARE_DEPLOYMENT.md; update README.md with Cloudflare Pages deployment info.
  • Repo Hygiene:
    • Update .gitignore for Cloudflare artifacts (.open-next/, .dev.vars, .wrangler/).

Written by Cursor Bugbot for commit 8c1ae8c. This will update automatically on new commits. Configure here.

- Install @opennextjs/cloudflare adapter and wrangler
- Add wrangler.jsonc for Cloudflare Workers configuration
- Create open-next.config.ts for OpenNext adapter settings
- Update package.json with Cloudflare Pages build scripts
- Configure static asset caching with public/_headers
- Update .gitignore for Cloudflare build artifacts
- Add comprehensive deployment documentation in CLOUDFLARE_DEPLOYMENT.md
- Update README with Cloudflare Pages deployment information

This enables free deployment to Cloudflare Pages with:
- Unlimited developers (vs Vercel's single-user free tier)
- 500 builds/month (sufficient for small teams)
- Unlimited bandwidth
- Full Next.js SSR support via Cloudflare Workers
- Airtable API integration compatibility
Add post-build script to copy worker.js to _worker.js in assets directory.
This ensures the Cloudflare Worker is deployed alongside static assets,
enabling dynamic routes, API routes, and server-side rendering.

- Add scripts/cloudflare-postbuild.sh to copy worker after build
- Update pages:build script to run post-build step
- Update deployment docs with correct build command
Cloudflare Pages automatic Git integration doesn't work correctly with
OpenNext Cloudflare's build structure. Instead, use GitHub Actions to
deploy via wrangler CLI, which properly handles the worker + assets.

Changes:
- Add .github/workflows/deploy-cloudflare-pages.yml for automated deployment
- Update CLOUDFLARE_DEPLOYMENT.md with GitHub Actions setup instructions
- Remove post-build script (no longer needed with CLI deployment)
- Revert pages:build to standard OpenNext command

This approach:
- Deploys on push to main (production)
- Creates preview deployments for PRs
- Properly deploys both the Cloudflare Worker and static assets
- Uses npx opennextjs-cloudflare deploy which handles everything correctly
Create a comprehensive post-build script that copies all worker
dependencies into the assets directory, enabling Cloudflare Pages
Git integration to properly bundle the worker.

Changes:
- Add scripts/prepare-cloudflare-git-deploy.sh to copy worker and dependencies
- Add pages:build:git npm script for Git integration builds
- Update CLOUDFLARE_DEPLOYMENT.md with three deployment options:
  1. GitHub Actions (recommended for teams/CI)
  2. Cloudflare Git Integration (simple setup)
  3. Manual CLI (testing/one-off)
- Add comparison table to help users choose deployment method

The script copies:
- worker.js → assets/_worker.js
- cloudflare/ directory (images, init, skew-protection)
- server-functions/ directory
- middleware/ directory
- .build/ directory

This allows both GitHub Actions AND Cloudflare Git integration
to work, giving users flexibility in deployment approach.
Update documentation to include compatibility flags configuration.
Cloudflare Pages Git integration bundles the worker itself and needs
the nodejs_compat flag to be set in the dashboard, not just in
wrangler.jsonc.

Required flags:
- nodejs_compat (for Node.js built-ins like async_hooks, fs, path, etc.)
- global_fetch_strictly_public (for fetch polyfills)
- Compatibility date: 2024-09-23 or later

These must be configured in:
Cloudflare Dashboard > Pages Project > Settings > Functions > Compatibility flags
@vercel
Copy link

vercel bot commented Nov 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
software-x-climate Ready Ready Preview Comment Nov 10, 2025 10:33pm

@jason-curtis jason-curtis changed the title Evaluate GitHub Pages deployment feasibility Evaluate CloudFlare Pages deployment feasibility Nov 10, 2025
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

"pages:build": "npx opennextjs-cloudflare build",
"pages:build:git": "npm run pages:build && bash scripts/prepare-cloudflare-git-deploy.sh",
"pages:preview": "npm run pages:build && npx opennextjs-cloudflare preview",
"pages:deploy": "npm run pages:build && npx opennextjs-cloudflare deploy"
Copy link

Choose a reason for hiding this comment

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

Bug: Standardize Package Manager Usage

The pages:build:git, pages:preview, and pages:deploy scripts use npm run instead of pnpm run, creating a package manager inconsistency. The project uses pnpm everywhere else (install commands, documentation, GitHub workflow), so these scripts will fail if npm isn't installed or if the package-lock.json doesn't exist.

Fix in Cursor Fix in Web

- Check if environment variables are set (showing partial values)
- Test Cloudflare API token validity before deployment
- Provide clear error messages for common authentication issues

This will help diagnose the authentication error without exposing
sensitive credentials in the logs.
cd .open-next

echo " → Copying worker to assets/_worker.js"
cp worker.js assets/_worker.js
Copy link

Choose a reason for hiding this comment

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

Bug: Directory Validation Prevents Cryptic Build Errors

The script attempts to copy worker.js to assets/_worker.js without verifying that the assets directory exists. With set -e enabled, the script will fail with a cryptic error if the assets directory is missing due to a partial build failure or changes in OpenNext's output structure. The script validates .open-next exists but doesn't check for or create the assets subdirectory before copying files into it.

Fix in Cursor Fix in Web

if [ -z "$CLOUDFLARE_ACCOUNT_ID" ]; then
echo "❌ CLOUDFLARE_ACCOUNT_ID is not set!"
else
echo "✅ CLOUDFLARE_ACCOUNT_ID is set: $CLOUDFLARE_ACCOUNT_ID"
Copy link

Choose a reason for hiding this comment

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

Bug: Sensitive Account IDs Exposed in Logs

The workflow logs the full CLOUDFLARE_ACCOUNT_ID in plain text to GitHub Actions logs. While less sensitive than API tokens, account IDs are still considered sensitive information that could aid attackers in targeting specific accounts and should not be exposed in logs.

Fix in Cursor Fix in Web

body=$(echo "$response" | sed '/HTTP_CODE:/d')

echo "Response code: $http_code"
echo "Response body: $body"
Copy link

Choose a reason for hiding this comment

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

Bug: Stop Logging Sensitive API Responses

The workflow logs the full API response body from Cloudflare's token verification endpoint, which may contain sensitive token metadata or account information that shouldn't be exposed in GitHub Actions logs accessible to repository collaborators.

Fix in Cursor Fix in Web

"https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/tokens/verify")

echo "Full token verification response:"
echo "$response" | jq '.' || echo "$response"
Copy link

Choose a reason for hiding this comment

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

Bug: Sensitive Data Leaks in Public Logs

The workflow logs the complete token verification response which may contain sensitive token details, permissions, and metadata that shouldn't be exposed in publicly accessible GitHub Actions logs.

Fix in Cursor Fix in Web

account_body=$(echo "$account_response" | sed '/HTTP_CODE:/d')

echo "Account access response code: $account_http_code"
echo "$account_body" | jq '.' || echo "$account_body"
Copy link

Choose a reason for hiding this comment

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

Bug: Sensitive Data Leak in Workflow Logs

The workflow logs the full account API response body which may contain sensitive account details, settings, and metadata beyond just the account name that shouldn't be exposed in GitHub Actions logs.

Fix in Cursor Fix in Web

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