This repo is set up for Cloudflare Pages plus Cloudflare Pages Functions.
You do not need a separate standalone Worker project for the backend. The file under functions/api/github.js is deployed in the Workers runtime automatically as part of the Pages project.
- Static frontend: Next.js static export from
out/ - Backend endpoint:
functions/api/github.js - Browser API contract:
/api/github?type=org/api/github?type=repos
Make sure the canonical repo is the org repo:
git remote -vRecommended remotes:
origin→https://github.com/boringcode-dev/boringcode.dev.gitpersonal→https://github.com/phatpham9/boringcode.dev.git
In Cloudflare dashboard:
- Go to Workers & Pages.
- Click Create application.
- Choose the Pages tab.
- Choose Import an existing Git repository.
- Select
boringcode-dev/boringcode.dev. - In build settings, start from the Next.js (Static HTML Export) preset.
Use these settings:
- Production branch:
main - Build command:
npx next build - Build output directory:
out - Root directory:
/
Notes:
- Start from the Cloudflare Next.js (Static HTML Export) preset.
- Cloudflare's preset uses
npx next build, which is fine for this repo. - Dependency installation still follows the detected lockfile/package-manager behavior during the Pages build.
Add this in the Cloudflare Pages project settings:
- Variable name:
GITHUB_TOKEN - Type: secret
- Environment: Production and Preview
Use a token that can read the org metadata and public repositories.
Notes:
- The site will still work without a token, but rate limits are tighter.
- For a quick start, a PAT is fine.
- For stricter org ownership later, migrate to a GitHub App.
After the Pages project is connected to GitHub:
- every push to
maintriggers a production deploy - every pull request / branch push gets a preview deploy
- the Pages Function under
functions/deploys together with the static site
You do not need a second CI pipeline just to deploy the API route.
Install dependencies:
pnpm installBuild the static site:
npx next buildOptional local Pages preview with Functions:
pnpm dlx wrangler pages dev outThat preview should serve:
- the static site from
out/ - the Pages Function from
functions/
After the first deploy, verify:
/api/github?type=orgreturns JSON/api/github?type=reposreturns JSON- homepage renders repo cards
- dark mode still works
- service worker registers from
/sw.js - preview deployments work on branch pushes / pull requests
- custom domain
boringcode.devis attached to the Pages project
After preview looks correct:
- Open the Pages project.
- Go to Custom domains.
- Add
boringcode.dev. - Follow Cloudflare DNS prompts.
- Wait for certificate issuance and domain activation.
If a deploy is bad:
- use the Cloudflare Pages deployment history to redeploy a previous good build
- or revert the bad commit on
main
Because the backend is attached to the same Pages project, rollback restores both frontend and function together.