Setup

Prerequisites

Installation

npm install

Configuration

Edit wrangler.jsonc to set your origin server URL:

"vars": {
    "PROXY_ORIGINAL_URL": "https://your-origin.com/images"
}

Create the R2 bucket

npx wrangler r2 bucket create worker-cdn-images

Generate types

npx wrangler types

Local development

Start the dev origin server:

cd server && npm install && node index.js

In another terminal, start the worker:

npm run dev

The worker runs at http://localhost:8787.

Deploy

npx wrangler deploy