Build your own website hosting platform using Cloudflare Workers for Platforms. Users can create and deploy websites through a simple web interface.
- Website Builder UI - Web interface for creating and deploying sites
- Static Site Hosting - Drag & drop HTML/CSS/JS files
- Custom Worker Code - Write dynamic sites with Workers
- Subdomain Routing - Each site gets
sitename.yourdomain.com - Custom Domains - Users can connect their own domains with SSL
- Admin Dashboard - Manage all sites at
/admin
Click the Deploy to Cloudflare button above. Everything is auto-configured!
If you want to use your own domain instead of *.workers.dev:
| Variable | Description |
|---|---|
CUSTOM_DOMAIN |
Your root domain (e.g., platform.com) |
┌─────────────────────────────────────────────────────────────┐
│ Your Platform (this template) │
├─────────────────────────────────────────────────────────────┤
│ platform.com → Website Builder UI │
│ platform.com/admin → Admin Dashboard │
├─────────────────────────────────────────────────────────────┤
│ User Sites (Workers for Platforms) │
│ ├── site1.platform.com → User's deployed Worker │
│ ├── site2.platform.com → User's deployed Worker │
│ └── custom.userdomain.com → Custom domain with SSL │
├─────────────────────────────────────────────────────────────┤
│ my.platform.com → Fallback origin for CNAMEs │
└─────────────────────────────────────────────────────────────┘
# Clone
git clone https://github.com/dinasaur404/platform-template.git
cd platform-template
# Install
npm install
# Run interactive setup (creates tokens, configures everything)
npm run setup
# Deploy
npm run deployThe setup script will:
- Validate your Cloudflare credentials
- Create the dispatch namespace for Workers for Platforms
- Auto-create API tokens with correct permissions (if needed)
- Generate
.dev.varswith all required configuration - Update
wrangler.tomlwith your settings
To use your own domain instead of *.workers.dev:
[vars]
CUSTOM_DOMAIN = "platform.com"
CLOUDFLARE_ZONE_ID = "your-zone-id-here"
FALLBACK_ORIGIN = "my.platform.com"
routes = [
{ pattern = "*/*", zone_name = "platform.com" }
]
workers_dev = falseIn your Cloudflare DNS settings for platform.com:
| Type | Name | Content | Result | Proxy |
|---|---|---|---|---|
| A | * |
192.0.2.1 |
*.platform.com |
Proxied |
| A | my |
192.0.2.1 |
my.platform.com |
Proxied |
Note: The root domain (
platform.com) is automatically configured when you add a custom domain to your Worker in the Cloudflare dashboard. The192.0.2.1is a dummy IP - Cloudflare's proxy handles the actual routing.
About the Fallback Origin (my.platform.com):
This is the hostname your customers will CNAME their custom domains to. When a user wants to connect their own domain (e.g., shop.example.com), they add:
CNAME shop.example.com → my.platform.com
Cloudflare uses this fallback origin to route traffic for custom hostnames.
npm run deployThe admin page (/admin) shows all projects. Protect it with Cloudflare Access:
- Go to Zero Trust → Access → Applications
- Add application for
platform.com/admin* - Configure authentication policy
| Problem | Solution |
|---|---|
| "Dispatch namespace not found" | Enable Workers for Platforms: dash.cloudflare.com/?to=/:account/workers-for-platforms |
| "Custom domain not working" | Check Zone ID and DNS records are correct |
| "Custom hostnames require additional setup" | Provide CLOUDFLARE_API_TOKEN with SSL permissions during deploy, or add it post-deploy as a secret |
| "404 on deployed sites" | Ensure uploaded files include index.html at the root |
| Database errors | Visit /admin to check status, or /init to reset |
View logs:
npx wrangler tail- Cloudflare Account with Workers for Platforms enabled
- Purchase Workers for Platforms or contact sales (Enterprise)
- Node.js 18+
Apache-2.0