Skip to content

Conversation

@rjocoleman
Copy link

@rjocoleman rjocoleman commented May 28, 2025

This PR adds Cloudflare Workers Static Assets as a new deployment method.
Is is a direct API integration, and could replace the to the existing Cloudflare Pages deployment method via Github.

Overview

This implementation uses Cloudflare Workers' static asset hosting capabilities to deploy sites directly to Cloudflare's edge network. It's strongly recommended by Cloudflare that new projects use this rather than CloudFlare Pages.

Key Features & Changes

Core Functionality:
• New CloudflareWorkers deployment class (cloudflare-workers.js) with full upload/deployment pipeline
• Direct API integration with Cloudflare Workers Static Assets API
• Automatic file hashing and deduplication for efficient uploads
• Batch file upload system using form-data multipart uploads
• Auto-generated worker script that serves static assets with proper routing

Configuration & UI:
• New deployment option in server settings with Cloudflare logo
• Three required configuration fields: Account ID, API Token, and Worker Name
• Secure credential storage via keytar
• Connection testing functionality to validate API access
• Form validation and error handling

Technical Implementation:
• Follows existing Publii deployment patterns and idioms
• Integrated into main deployment system (deployment.js)
• Support for 404s via the existing 404.html in worker configuration
• Auto-trailing-slash HTML handling for clean URLs
• Progress tracking and status reporting during deployment

Setup Requirements:
• Cloudflare account with Workers plan (free is fine)
• API token with Workers edit permissions
• Account ID from Cloudflare dashboard
• Worker name (can be created via one of the Cloudflare onboarding starters, gets overwritten)
• Optional: Custom domain can be later added via Cloudflare Workers Web UI

Refs: #2049 #996 #1174

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant