This repository now uses Cloudflare Pages for static hosting and Cloudflare Workers for the API endpoints.
- Frontend now calls
/api/gravatarand/api/githubinstead of Netlify function paths. worker.jscontains the Cloudflare Worker handlers for Gravatar and GitHub.wrangler.tomlconfigures Wrangler for local development and deploys.package.jsonno longer depends on Netlify-specific packages.
- On Cloudflare Pages, configure the repository.
- Build command:
npm run build - Publish directory:
dist
- Install dependencies:
npm install - Run locally:
npm run dev:worker - Deploy:
npm run deploy:worker
Set these Cloudflare Worker secrets after you log in:
wrangler secret put GITHUB_API_KEY
wrangler secret put GRAVATAR_API_KEYIf GITHUB_API_KEY is not provided, the worker will still attempt an unauthenticated request, but using the token is recommended.
- If you want the same domain for both Pages and the Worker, route
/api/*to the worker from your Cloudflare dashboard or use a custom domain with a worker route. - The static app still builds with Vite and publishes from
dist.
For a single domain like example.com, map all API requests to the worker while serving static files from Pages.
- Deploy the Pages site normally.
- Deploy the worker and configure a Cloudflare route for
/api/*.
Example wrangler.toml route config:
name = "lawrenceee04-pages-api"
main = "worker.js"
compatibility_date = "2026-06-28"
type = "javascript"
# Uncomment these to deploy the worker to your custom domain route
# account_id = "<YOUR_CLOUDFLARE_ACCOUNT_ID>"
# zone_id = "<YOUR_ZONE_ID>"
# route = "example.com/api/*"With this setup:
https://example.comserves the Pages sitehttps://example.com/api/githuband/api/gravatarare routed to the worker- browser requests to
/api/*are handled by the worker while all other paths remain static