This project is configured to deploy to Cloudflare Workers with static assets using Wrangler CLI.
npm install- Sign up/login to Cloudflare Dashboard
- Get your Account ID from the right sidebar
- Create an API token at API Tokens
- Use the "Edit Cloudflare Workers" template
- Copy the generated token
cp .env.example .env
# Edit .env and add your CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKENAdd these secrets to your GitHub repository:
CLOUDFLARE_ACCOUNT_ID: Your Cloudflare account IDCLOUDFLARE_API_TOKEN: Your Cloudflare API token
Go to: Repository Settings → Secrets and Variables → Actions → New repository secret
# Deploy to Cloudflare Workers
npm run deploy-cf-worker- Staging: Deploys automatically on pull requests to
main - Production: Deploys automatically when pushing to
mainbranch
wrangler.toml: Cloudflare Workers configuration with static assetssrc/worker.js: Worker script for handling static file serving.github/workflows/deploy-cloudflare.yml: GitHub Actions workflowpackage.json: Contains thedeploy-cf-workerscript
This setup uses Cloudflare Workers with static assets to:
- Serve your Docusaurus build files from the
./builddirectory - Handle SPA routing for client-side navigation
- Provide fast global edge distribution
- Production:
treasurenet-docs(main branch) - Staging:
treasurenet-docs-staging(pull requests)
npm run build: Build the Docusaurus sitenpm run deploy-cf-worker: Build and deploy to Cloudflare Workersnpx wrangler dev: Local development with Wranglernpx wrangler deploy: Deploy to production
- Authentication errors: Ensure your API token has the correct permissions
- Project name conflicts: Update the project name in
wrangler.tomlandpackage.json - Build failures: Check that
npm run buildworks locally first