Skip to content

feat(deploy): configure Cloudflare Pages deployment#57

Merged
meshackyaro merged 9 commits into
trustflow-protocol:mainfrom
stephanieoghenemega-eng:feat/issue-5-cloudflare-pages-deploy
Jun 29, 2026
Merged

feat(deploy): configure Cloudflare Pages deployment#57
meshackyaro merged 9 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.

stephanieoghenemega-eng and others added 6 commits June 24, 2026 17:38
…ibility

`@cloudflare/next-on-pages` requires all non-static routes to export
`runtime = 'edge'`. Converts the handler from NextApiRequest/NextApiResponse
to NextRequest/NextResponse, reading query params from URL.searchParams
instead of req.query.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
GitHub withholds repo secrets from fork PR workflows (Secret source: None),
so the deploy step can never succeed on pull_request events. Restricting
to push ensures the workflow only runs post-merge when secrets are available.
@meshackyaro meshackyaro force-pushed the feat/issue-5-cloudflare-pages-deploy branch from b6790b6 to a9bbb53 Compare June 29, 2026 02:48
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
trustflow-frontend Ready Ready Preview, Comment Jun 29, 2026 2:52am

@meshackyaro meshackyaro merged commit ac9f846 into trustflow-protocol:main Jun 29, 2026
4 checks passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jun 29, 2026
10 tasks
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