feat(deploy): configure Cloudflare Pages deployment#57
Open
stephanieoghenemega-eng wants to merge 7 commits into
Open
Conversation
|
@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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-pagesadapter.Changes
wrangler.toml(new)Minimal config pointing Wrangler at the Pages project and the adapter's output directory:
nodejs_compatis 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
mainand on PRs (preview deployments). Steps:npm cinpx @cloudflare/next-on-pages— builds the Next.js app and adapts it for the CF edge runtimecloudflare/pages-action@v1— publishes to thetrustflow-frontendPages projectSecrets required in the repository settings:
CLOUDFLARE_API_TOKEN— a CF API token with Cloudflare Pages: Edit permissionCLOUDFLARE_ACCOUNT_ID— your Cloudflare account IDPR deployments automatically get a preview URL posted back as a comment via
gitHubToken.next.config.jsIntegrated the
@cloudflare/next-on-pages/next-devsetup call for local development (no-op in production):i18n note: Cloudflare Pages runs on the Workers edge runtime which doesn't support Next.js's Node.js-based i18n middleware. The
i18nconfig is kept as-is foruseRouter().localeto work in the Pages Router; locale detection on the edge should be handled via afunctions/_middleware.tsfile using theAccept-Languageheader if needed. This is noted in a comment innext.config.js.Install the adapter
This needs to be added to
package.jsonbefore the workflow will succeed.Test plan
npx @cloudflare/next-on-pageslocally → build completes,.vercel/output/staticpopulatednpx wrangler pages dev .vercel/output/static→ site serves on localhostmain→ GitHub Actions workflow runs, site deploys to Cloudflare Pages