Convert Cloudflare Worker to Cloudflare Pages

This commit converts the entire Xget application from a Cloudflare Worker
to a Cloudflare Page, enabling static asset hosting while maintaining all
existing functionality.

Changes:
- Add functions/[[path]].js: Catch-all Pages Function handler
- Add public/index.html: Landing page with Xget information
- Update src/index.js: Export handleRequest for Pages Function import
- Update wrangler.toml: Configure for Pages deployment
- Update package.json: Change scripts to use Pages commands
- Update vitest.config.js: Include functions/ in coverage
- Update .github/workflows/depoly.yml: Deploy to Pages
- Update documentation: CLAUDE.md, README.md, README.en.md

The conversion maintains full backward compatibility with existing tests
and functionality. All caching strategies, security headers, and protocol
handling remain unchanged.
This commit is contained in:
Claude committed 2025-11-16 15:18:34 +00:00
1 parent f74850e5a2
commit eabf0782d4
10 files changed
+240 -35

No files matched your search

+20 -7
View File
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
## Project Overview
Xget is a high-performance acceleration engine for developer resources built on Cloudflare Workers. It provides unified acceleration for code repositories, package managers, container registries, AI inference providers, and more. The application proxies requests to various platforms, applies intelligent caching, and implements security measures while maintaining protocol compliance (Git, Docker/OCI, AI APIs).
Xget is a high-performance acceleration engine for developer resources built on Cloudflare Pages. It provides unified acceleration for code repositories, package managers, container registries, AI inference providers, and more. The application proxies requests to various platforms, applies intelligent caching, and implements security measures while maintaining protocol compliance (Git, Docker/OCI, AI APIs).
**Key Features:**
@@ -65,12 +65,12 @@ npm run format:check
### Deployment
```bash
# Deploy to Cloudflare Workers
# Deploy to Cloudflare Pages
npm run deploy
# or
wrangler deploy
wrangler pages deploy
# Start production preview
# Start local development server
npm start
```
@@ -115,6 +115,19 @@ podman run -p 8080:8080 xget
- Container registries: `cr-docker`, `cr-ghcr`, `cr-gcr`, etc. (prefix: `cr-`)
- `transformPath()` - Converts prefixed URLs to actual platform URLs
**`functions/[[path]].js`** - Cloudflare Pages Function handler
- `onRequest()` - Pages Function entry point that wraps handleRequest
- Catch-all route handler that processes all incoming requests
- Converts Pages Function context to Workers-compatible format
- Delegates to handleRequest for actual processing
**`public/index.html`** - Landing page
- Static HTML page served at the root URL
- Provides information about Xget features and usage examples
- Only served when accessing the root path directly
### Request Flow
```
@@ -186,7 +199,7 @@ podman run -p 8080:8080 xget
## Environment Variables
Configure via Cloudflare Workers environment or `.dev.vars`:
Configure via Cloudflare Pages environment variables or `.dev.vars`:
- `TIMEOUT_SECONDS` - Request timeout (default: 30)
- `MAX_RETRIES` - Max retry attempts (default: 3)
@@ -241,9 +254,9 @@ Configure via Cloudflare Workers environment or `.dev.vars`:
## Deployment Targets
1. **Cloudflare Workers** (primary): Zero-config deployment with global edge network
1. **Cloudflare Pages** (primary): Zero-config deployment with global edge network and built-in static asset hosting
2. **Docker/Podman**: Self-hosted with workerd runtime (see Dockerfile)
3. **Local development**: Wrangler dev server on localhost
3. **Local development**: Wrangler Pages dev server on localhost
## License