Worker Deployment Success! πο
β Worker Script Deployed Successfullyο
The Cloudflare Worker has been deployed via API and is now ready to serve tenant sites from R2!
Deployment Summaryο
What Was Deployedο
Worker Script: getaipage-router
Size: 5,779 bytes
Account ID: 6451353ea5a8407bab6162abc42f5338
Zone ID: 2cf1f02313c4ef76af3d62eb78bb906e
Status: β Deployed and Active
R2 Binding:
Bucket:
getaipageBinding Name:
MY_BUCKETRegion: WNAM (Western North America)
Worker Route:
Pattern:
*.getai.page/*Route ID: 245446fc252e4a55810d7169ffbbf294
Status: β Active
Environment Variables:
PLATFORM_DOMAIN:getai.pageINTERNAL_API_KEY: (configured)
How It Worksο
Request Flowο
Browser requests:
https://tenant-getaipage2.getai.page/index.htmlWorker receives request:
Extracts host header:
tenant-getaipage2.getai.pageResolves tenant ID:
tenant-getaipage2
Worker fetches from R2:
Constructs R2 key:
tenant-getaipage2/index.htmlGets object from
MY_BUCKET(getaipage)
Worker returns response:
Sets appropriate Content-Type
Adds cache headers
Returns file content
Featuresο
β
Multi-tenant routing - Each subdomain maps to a tenant folder in R2
β
R2 storage - Files served directly from R2 bucket
β
Smart caching - Different cache rules for HTML vs static assets
β
SPA support - Fallback to index.html for client-side routing
β
CORS headers - Configured for cross-origin requests
β
Security headers - X-Content-Type-Options, X-Frame-Options
β
Health check - /_health endpoint
Deployment Methodο
Using the API Scriptο
python deploy_worker.py
This script:
Reads the worker template from
cloudflare_saas/worker_template.jsCreates metadata with R2 bindings and environment variables
Uploads worker as a module to Cloudflare
Creates/updates worker route for
*.getai.page/*Verifies deployment
Key API Endpoints Usedο
Upload Worker:
PUT /accounts/{account_id}/workers/scripts/{script_name}
Multipart form data with metadata + module file
Create/Update Route:
POST /zones/{zone_id}/workers/routes PUT /zones/{zone_id}/workers/routes/{route_id}
Complete System Statusο
β Working Componentsο
API Token - 8/8 permissions passing
R2 Bucket -
getaipagecreated and accessible (region: auto)Worker Script - Deployed and bound to R2
Worker Route - Active for
*.getai.page/*Tenant Creation - Working via platform API
File Upload - 38 files uploaded successfully to R2
Custom Domains - Configuration working
Full Deployment Exampleο
python examples/full_deployment_example.py \
/Users/baneet/Documents/temp/temp5/out \
getaipage2 \
getai.page
Results:
β Tenant created:
tenant-getaipage2β Files deployed: 38 files (1.4MB) in ~15 seconds
β Subdomain:
tenant-getaipage2.getai.pageβ Custom domain configured:
getai.page
Testing the Deploymentο
Via DNS (Requires DNS Configuration)ο
The worker is ready to serve requests at:
https://tenant-getaipage2.getai.page/
DNS Requirements:
Add DNS record for
*.getai.pagepointing to CloudflareThis enables the worker to receive requests
Via Worker URL (Direct Access)ο
Workers can also be accessed via:
https://getaipage-router.<account-subdomain>.workers.dev/
Health Checkο
curl https://tenant-getaipage2.getai.page/_health
# Should return: OK
Worker Code Featuresο
Cache Strategyο
HTML Files:
'public, max-age=0, s-maxage=60, must-revalidate'
Browser: No cache (always check)
CDN: 60 seconds
Static Assets (CSS, JS, images):
'public, max-age=604800, immutable, s-maxage=604800'
Browser: 7 days
CDN: 7 days
Immutable flag for better performance
Tenant Resolutionο
Subdomain Pattern:
tenant-getaipage2.getai.page β tenant-getaipage2
Custom Domain (via API):
getai.page β query platform API β tenant-getaipage2
R2 Path Mappingο
Request: /assets/logo.png
Tenant: tenant-getaipage2
R2 Key: tenant-getaipage2/assets/logo.png
Next Stepsο
To Make Sites Accessibleο
Configure DNS for getai.page
Add NS records or transfer DNS to Cloudflare
Or add a wildcard CNAME if using external DNS
Test Worker
Once DNS is configured, test:
https://tenant-getaipage2.getai.page/Check browser dev tools for proper content-type and cache headers
Monitor Worker
View logs at: https://dash.cloudflare.com/6451353ea5a8407bab6162abc42f5338/workers/services/view/getaipage-router
Check metrics for requests, errors, CPU time
Optional Enhancementsο
Add Custom Hostnames
Already configured in platform API
Requires DNS verification to activate
Enable Analytics
Workers Analytics automatically enabled
Can add custom analytics events
Add Rate Limiting
Use Cloudflare Rate Limiting rules
Or implement in worker code
Add Authentication
Can add JWT validation in worker
Or use Cloudflare Access
Files Created/Modifiedο
β
deploy_worker.py- Worker deployment script via APIβ
cloudflare_saas/worker_template.js- Worker code (existing)β
WORKER_DEPLOYMENT.md- This documentation
Environment Configurationο
All required environment variables in .env:
# Cloudflare API
CLOUDFLARE_API_TOKEN=2MfCcf2yvvTUjzNtfVcD-UIy6bf6t_wnPcSc9MqV
CLOUDFLARE_ACCOUNT_ID=6451353ea5a8407bab6162abc42f5338
CLOUDFLARE_ZONE_ID=2cf1f02313c4ef76af3d62eb78bb906e
# R2 Storage
R2_BUCKET_NAME=getaipage
R2_ENDPOINT=https://6451353ea5a8407bab6162abc42f5338.r2.cloudflarestorage.com
R2_ACCESS_KEY_ID=<your-key>
R2_SECRET_ACCESS_KEY=<your-secret>
# Platform
PLATFORM_DOMAIN=getai.page
WORKER_SCRIPT_NAME=getaipage-router
INTERNAL_API_KEY=your-internal-api-key-here
Troubleshootingο
Worker Not Receiving Requestsο
Check DNS is configured for
*.getai.pageVerify route is active in Cloudflare dashboard
Check zone is on Cloudflare (Orange Cloud enabled)
Files Not Found (404)ο
Verify files uploaded to R2: Check bucket in dashboard
Check R2 key format: Should be
tenant-id/file-pathTest R2 access with boto3 (use
region_name='auto')
CORS Errorsο
Worker sets
access-control-allow-origin: *Can customize in
cloudflare_saas/worker_template.js
Performance Issuesο
Check worker CPU time in dashboard
Verify R2 bucket is in optimal region
Review cache hit ratio
Success Metricsο
β Worker deployed: YES β R2 binding configured: YES β Route active: YES β Environment variables set: YES β Ready to serve traffic: YES (pending DNS)
β
Status: π Complete and ready to serve traffic Date: 2025-12-18 Worker Name: getaipage-router Dashboard: https://dash.cloudflare.com/6451353ea5a8407bab6162abc42f5338/workers/services/view/getaipage-router