Skip to content

feat(deploy): configure Cloudflare Pages deployment#57

Open
stephanieoghenemega-eng wants to merge 7 commits into
trustflow-protocol:mainfrom
stephanieoghenemega-eng:feat/issue-5-cloudflare-pages-deploy
Open

feat(deploy): configure Cloudflare Pages deployment#57
stephanieoghenemega-eng wants to merge 7 commits into
trustflow-protocol:mainfrom
stephanieoghenemega-eng:feat/issue-5-cloudflare-pages-deploy

Conversation

@stephanieoghenemega-eng

Copy link
Copy Markdown
Contributor

Closes #5

Summary

Adds everything needed to deploy the frontend/ directory to Cloudflare's edge network via Cloudflare Pages, using the official @cloudflare/next-on-pages adapter.

Changes

wrangler.toml (new)

Minimal config pointing Wrangler at the Pages project and the adapter's output directory:

name = "trustflow-frontend"
compatibility_date = "2024-09-23"
compatibility_flags = ["nodejs_compat"]

pages_build_output_dir = ".vercel/output/static"

nodejs_compat is required because Next.js uses Node.js built-ins (crypto, buffer, etc.) that aren't available in the base Workers runtime.

.github/workflows/deploy-cf-pages.yml (new)

Triggers on every push to main and on PRs (preview deployments). Steps:

  1. Checkout + Node 20 + npm ci
  2. npx @cloudflare/next-on-pages — builds the Next.js app and adapts it for the CF edge runtime
  3. cloudflare/pages-action@v1 — publishes to the trustflow-frontend Pages project

Secrets required in the repository settings:

  • CLOUDFLARE_API_TOKEN — a CF API token with Cloudflare Pages: Edit permission
  • CLOUDFLARE_ACCOUNT_ID — your Cloudflare account ID

PR deployments automatically get a preview URL posted back as a comment via gitHubToken.

next.config.js

Integrated the @cloudflare/next-on-pages/next-dev setup call for local development (no-op in production):

const { setupDevPlatform } = process.env.NODE_ENV === 'development'
  ? require('@cloudflare/next-on-pages/next-dev')
  : { setupDevPlatform: () => {} };

i18n note: Cloudflare Pages runs on the Workers edge runtime which doesn't support Next.js's Node.js-based i18n middleware. The i18n config is kept as-is for useRouter().locale to work in the Pages Router; locale detection on the edge should be handled via a functions/_middleware.ts file using the Accept-Language header if needed. This is noted in a comment in next.config.js.

Install the adapter

npm install --save-dev @cloudflare/next-on-pages

This needs to be added to package.json before the workflow will succeed.

Test plan

  • npx @cloudflare/next-on-pages locally → build completes, .vercel/output/static populated
  • npx wrangler pages dev .vercel/output/static → site serves on localhost
  • Push to main → GitHub Actions workflow runs, site deploys to Cloudflare Pages
  • Open a PR → preview URL posted as a comment

@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

@stephanieoghenemega-eng is attempting to deploy a commit to the Meshack Yaro 's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Configure Cloudflare Pages deployment

2 participants