This guide covers deploying BLT-Next to GitHub Pages for the frontend and Cloudflare Workers for the backend API.
- GitHub account with access to the repository
- Cloudflare account (free tier works)
- Git installed locally
- Node.js 18+ (for Wrangler CLI)
- Python 3.11+ (for local worker development)
- Go to your repository on GitHub
- Navigate to Settings > Pages
- Under Source, select:
- Source: Deploy from a branch
- Branch: main
- Folder: / (root)
- Click Save
The GitHub Actions workflow (.github/workflows/pages.yml) will automatically deploy your site.
- Go to Actions tab in your repository
- You should see a workflow run for "Deploy to GitHub Pages"
- Wait for it to complete (usually 1-2 minutes)
- Your site will be live at:
https://owasp-blt.github.io/BLT-Next/
To use a custom domain:
-
Add a
CNAMEfile in the repository root:blt.example.com -
Configure DNS with your domain provider:
CNAME record: blt.example.com → owasp-blt.github.io -
In GitHub Pages settings, add your custom domain
-
Enable Enforce HTTPS
npm install -g wranglerVerify installation:
wrangler --versionwrangler loginThis will open a browser window to authenticate with Cloudflare.
If using Cloudflare D1 for database:
wrangler d1 create blt-databaseCopy the database ID from the output and update wrangler.toml:
[[d1_databases]]
binding = "DB"
database_name = "blt-database"
database_id = "your-database-id-here"Set environment secrets for the worker:
# JWT secret for authentication
wrangler secret put JWT_SECRET
# Enter a strong random string
# Database URL (if using external database)
wrangler secret put DATABASE_URL
# Enter your database connection string
# Encryption key
wrangler secret put ENCRYPTION_KEY
# Enter a strong random stringEdit wrangler.toml:
- Update
nameto your desired worker name - Update
routewith your custom domain (or remove for *.workers.dev) - Configure environment variables if needed
wrangler deployYour API will be deployed and you'll get a URL like:
https://blt-api.<YOUR_CLOUDFLARE_ACCOUNT>.workers.dev
Replace <YOUR_CLOUDFLARE_ACCOUNT> with your actual Cloudflare account subdomain.
Update the API endpoint in src/assets/js/main.js:
const CONFIG = {
// Replace with your actual Worker URL
API_BASE_URL: 'https://blt-api.<YOUR_CLOUDFLARE_ACCOUNT>.workers.dev',
// Or your custom domain:
// API_BASE_URL: 'https://api.<YOUR_DOMAIN>.com',
};IMPORTANT: Make sure to replace the placeholder URLs with your actual endpoints before deploying to production.
Commit and push the changes:
git add src/assets/js/main.js
git commit -m "Update API endpoint"
git pushIn workers/main.py, update ALLOWED_ORIGINS:
ALLOWED_ORIGINS = [
'https://owasp-blt.github.io',
'https://yourdomain.com', # Add your custom domain
'http://localhost:8000', # For local development
]Redeploy the worker:
wrangler deploy- Create database (already done in Step 3)
- Create schema:
wrangler d1 execute blt-database --file=schema.sqlExample schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT UNIQUE NOT NULL,
email TEXT UNIQUE NOT NULL,
password_hash TEXT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE bugs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
description TEXT,
severity TEXT,
status TEXT,
reporter_id INTEGER,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (reporter_id) REFERENCES users(id)
);If using PostgreSQL, MySQL, or another database:
- Set up your database
- Create tables using migration scripts
- Configure connection in worker secrets
- Update worker code to use database client
- Open your GitHub Pages URL
- Navigate through pages
- Test forms (will show errors until API is connected)
- Check browser console for errors
Test endpoints using curl:
# Test stats endpoint
curl https://blt-api.your-account.workers.dev/api/stats
# Test login
curl -X POST https://blt-api.your-account.workers.dev/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","password":"test123"}'- Monitor deployment status in Actions tab
- Check Pages settings for build status
- Go to Cloudflare Dashboard
- Navigate to Workers & Pages
- Click on your worker
- View metrics:
- Requests
- Errors
- CPU time
- Duration
In Cloudflare:
- Go to Notifications
- Create alerts for:
- High error rate
- Increased latency
- Rate limit exceeded
Automatically deploys on push to main branch via GitHub Actions.
Option 1: Manual Deployment
wrangler deployOption 2: GitHub Actions
Create .github/workflows/deploy-worker.yml:
name: Deploy Cloudflare Worker
on:
push:
branches: [main]
paths:
- 'workers/**'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
workingDirectory: 'workers'Add CLOUDFLARE_API_TOKEN to repository secrets.
- Check Actions tab for workflow failures
- Clear browser cache
- Wait a few minutes (CDN cache)
- Check Pages settings
-
Check worker logs:
wrangler tail
-
Check Cloudflare Dashboard for errors
-
Verify secrets are set correctly
-
Test endpoints individually
- Verify allowed origins in worker
- Check browser console for specific error
- Ensure proper headers are returned
- Test with curl to isolate issue
- Verify DATABASE_URL secret
- Check database is accessible
- Verify credentials
- Check firewall rules (if external DB)
- GitHub Pages deployed successfully
- Custom domain configured (if applicable)
- HTTPS enabled
- Worker deployed to production
- Secrets configured
- Database set up and migrated
- CORS configured correctly
- API endpoints tested
- Error monitoring set up
- Rate limiting configured
- Backup strategy in place
- Documentation updated
- Enable caching headers in
_config.yml - Compress images before committing
- Use CDN for large assets
- Minimize CSS/JS (optional, but recommended for production)
- Enable KV caching for frequently accessed data
- Optimize database queries
- Use connection pooling for external databases
- Monitor and optimize slow endpoints
- Free for public repositories
- Free tier: 100,000 requests/day
- Paid: $5/month for 10 million requests
- D1: Free up to 5 GB
Total estimated cost: $0-10/month depending on traffic
- Always use HTTPS
- Set strong JWT_SECRET
- Rotate secrets regularly
- Enable rate limiting
- Monitor for suspicious activity
- Keep dependencies updated
- Use Content Security Policy
- Issues: GitHub Issues
- Community: OWASP BLT Slack
- Docs: Project Documentation
After successful deployment:
- Test all features thoroughly
- Set up monitoring and alerts
- Configure backup strategy
- Document any custom configurations
- Train team on deployment process