In this post, I'll walk through building Petra Cloudinary Worker — a serverless Cloudinary credential manager and upload signing proxy that runs entirely on Cloudflare Workers. The dashboard lives at the edge too, rendered with Hono JSX.
What we're building
When you upload files to Cloudinary from a frontend app, you need a signature signed with your API secret. The standard approach is to expose that secret to the client, which is insecure, or run a backend server that signs requests.
This worker replaces that backend. It stores Cloudinary credentials for multiple Cloudinary accounts in Cloudflare KV, provides an API to generate upload signatures, and includes a dashboard to manage those credentials — all at the edge with zero cold starts.
Architecture flow:
Browser ──POST /api/sign──► Worker (looks up the account's
│ credentials in KV, returns
│ signed signature)
│
│ ──POST file + signature──► Cloudinary Upload API
│ (direct upload, no proxy)
│
◄──────── secure_url ─────────
Key features
- Multi-account — Store separate Cloudinary credentials for each account
- Direct upload — Files go straight from browser to Cloudinary (no bandwidth through worker)
- Edge signing — Signatures generated at the edge using Web Crypto
- Server-rendered dashboard — Full UI to register, edit, and delete Cloudinary accounts, rendered via Hono JSX
- Delete API — Server-side asset deletion via Cloudinary's destroy endpoint
- HTTP Basic Auth — Protect the dashboard with a simple password
- CORS enforcement — Restrict API access to specific origins
- CI/CD — GitHub Actions pipeline that tests and deploys
Prerequisites
- Node.js 22+
- A Cloudflare account with Workers enabled
- A Cloudinary account
- (Optional) A GitHub account for CI/CD
Step 1: Scaffold the project
We'll use Hono, a lightweight framework for Cloudflare Workers, with the Wrangler CLI.
npm create cloudflare@latest petra-cloudinary-worker -- --framework=hono cd petra-cloudinary-worker
This scaffolds a basic Hono + Cloudflare Worker project. Let's install the dependencies we'll need:
npm install hono npm install --save-dev wrangler@4 @cloudflare/workers-types@^5 vitest
Step 2: Configure Wrangler and KV
First, create a KV namespace in your Cloudflare account:
npx wrangler kv namespace create "cloudinary_tenants"
Save the returned ID — you'll need it in a moment.
The wrangler.jsonc config file ties everything together:
{ "$schema": "node_modules/wrangler/config-schema.json", "name": "petra-cloudinary-worker", "main": "src/index.ts", "compatibility_date": "2026-07-10", "kv_namespaces": [ { "binding": "TENANTS", "id": "YOUR_KV_NAMESPACE_ID", } ], "vars": {}, }
The TENANTS binding makes the KV store available as c.env.TENANTS in our worker code.
A quick note on vars: we keep it empty because we want CORS to be open by default. If you need to restrict origins later, you add ALLOWED_ORIGINS here, via .dev.vars, or as a Cloudflare secret.
Step 3: Define types
Good practice is to centralize your types. Here's what we need (src/types.ts):
export type Bindings = { TENANTS: KVNamespace ALLOWED_ORIGINS?: string AUTH_PASSWORD?: string } export type TenantData = { cloudName: string apiKey: string apiSecret: string } export type ResourceType = 'image' | 'raw' | 'video' export type SignResponse = { signature: string timestamp: number api_key: string cloud_name: string upload_preset?: string } export type DeleteResponse = { ok: boolean result: string }
Bindings defines the environment variables and KV bindings our worker receives from Cloudflare. TenantData is what we store per Cloudinary account. SignResponse and DeleteResponse define the API response shapes.
Step 4: The Cloudinary signature utility
Cloudinary upload authentication works via a SHA-1 signature. You sort the upload parameters alphabetically, join them as key=value&key=value, append the API secret, and hash the whole thing.
// src/utils/cloudinary.ts async function hashHex(algorithm: 'SHA-1' | 'SHA-256', input: string): Promise<string> { const digest = await crypto.subtle.digest(algorithm, new TextEncoder().encode(input)) return Array.from(new Uint8Array(digest)) .map(b => b.toString(16).padStart(2, '0')) .join('') } export function cloudinarySignature( params: Record<string, string | number>, apiSecret: string ): Promise<string> { const toSign = Object.keys(params) .sort() .map(k => `${k}=${params[k]}`) .join('&') return hashHex('SHA-1', toSign + apiSecret) } export async function generateSignature( uploadParams: Record<string, string>, apiSecret: string ): Promise<{ signature: string; timestamp: number }> { const timestamp = Math.floor(Date.now() / 1000) const toSign: Record<string, string | number> = { ...uploadParams, timestamp } const signature = await cloudinarySignature(toSign, apiSecret) return { signature, timestamp } } export async function destroyAsset( credentials: { apiKey: string; apiSecret: string; cloudName: string }, publicId: string, resourceType: ResourceType ): Promise<{ ok: boolean; result: string }> { const timestamp = Math.floor(Date.now() / 1000) const signature = await cloudinarySignature( { public_id: publicId, timestamp }, credentials.apiSecret ) const body = new URLSearchParams({ public_id: publicId, timestamp: String(timestamp), api_key: credentials.apiKey, signature }) const res = await fetch( `https://api.cloudinary.com/v1_1/${credentials.cloudName}/${resourceType}/destroy`, { method: 'POST', body } ) const data = (await res.json()) as { result?: string } return { ok: res.ok && data.result === 'ok', result: data.result ?? 'error' } }
We use crypto.subtle.digest which is available natively in Cloudflare Workers — no polyfills needed. The sorting step is critical: Cloudinary expects parameters in alphabetical order.
Tests
We should test this utility. Using Vitest:
// src/utils/cloudinary.test.ts import { describe, expect, it } from 'vitest' import { cloudinarySignature } from './cloudinary' describe('cloudinarySignature', () => { it('produces a SHA-1 hex signature from sorted params and secret', async () => { const result = await cloudinarySignature( { timestamp: 1750000000, folder: 'test' }, 'my_secret' ) expect(result).toMatch(/^[a-f0-9]{40}$/) }) it('sorts keys alphabetically before signing', async () => { const a = await cloudinarySignature({ b: '2', a: '1' }, 'secret') const b = await cloudinarySignature({ a: '1', b: '2' }, 'secret') expect(a).toBe(b) }) it('produces different signatures for different secrets', async () => { const a = await cloudinarySignature({ folder: 'x', timestamp: 1 }, 'secret_a') const b = await cloudinarySignature({ folder: 'x', timestamp: 1 }, 'secret_b') expect(a).not.toBe(b) }) it('handles empty params', async () => { const result = await cloudinarySignature({}, 'secret') expect(result).toMatch(/^[a-f0-9]{40}$/) }) })
Run tests with:
npm test
Step 5: CORS middleware
The API needs CORS headers so browsers can call it from different origins. We'll also support a wildcard mode for development.
// src/middleware/cors.ts import type { Context, Next } from 'hono' import type { Bindings } from '../types' export async function apiCors(c: Context<{ Bindings: Bindings }>, next: Next) { const origin = c.req.header('Origin') ?? '' const allowed = c.env.ALLOWED_ORIGINS?.split(',').map(s => s.trim()) ?? [] // If ALLOWED_ORIGINS is not set or contains '*', allow all const corsOrigin = !allowed.length || allowed.includes('*') ? '*' : allowed.includes(origin) ? origin : 'null' c.header('Access-Control-Allow-Origin', corsOrigin) c.header('Access-Control-Allow-Methods', 'POST, OPTIONS') c.header('Access-Control-Allow-Headers', 'Authorization, Content-Type') if (corsOrigin !== '*') { c.header('Vary', 'Origin') } if (c.req.method === 'OPTIONS') { return c.body(null, 204) } await next() }
When ALLOWED_ORIGINS is unset or *, we return Access-Control-Allow-Origin: * (permissive). When a comma-separated list is set, we validate the requesting origin against it.
Step 6: Basic Auth middleware
To protect the dashboard, we need something simple. HTTP Basic Auth is the quickest option — no login page, no session management, just a password check.
// src/middleware/auth.ts import type { Context, Next } from 'hono' import type { Bindings } from '../types' export async function basicAuth(c: Context<{ Bindings: Bindings }>, next: Next) { // No password set = no auth required if (!c.env.AUTH_PASSWORD) { await next() return } const header = c.req.header('Authorization') ?? '' const match = header.match(/^Basic\s+(.+)$/) if (!match) { c.header('WWW-Authenticate', 'Basic realm="Petra Cloudinary"') return c.text('Unauthorized', 401) } const decoded = atob(match[1]) const password = decoded.includes(':') ? decoded.split(':')[1] : '' if (password !== c.env.AUTH_PASSWORD) { c.header('WWW-Authenticate', 'Basic realm="Petra Cloudinary"') return c.text('Unauthorized', 401) } await next() }
If AUTH_PASSWORD is not set, the middleware is a no-op — the dashboard stays open. Set it, and the browser prompts for a username and password. The username is ignored (we only check the password).
Step 7: Shared UI components
The dashboard needs reusable UI components. We'll build them with Hono JSX and Tailwind CSS (loaded via CDN for simplicity).
Layout
The layout wraps every page with the HTML shell, Google Fonts (Inter), and Tailwind via CDN:
// src/components/layout.tsx import type { FC } from 'hono/jsx' export const Layout: FC<{ children?: any }> = ({ children }) => ( <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Petra Cloudinary</title> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet" /> <script src="https://unpkg.com/@tailwindcss/browser@4" /> <style>{` @theme { --color-background: #0A0A0F; --color-foreground: rgba(255,255,255,0.9); --color-card: #12121A; --color-primary: #2563EB; --color-muted-foreground: #8B8FA3; --color-border: rgba(255,255,255,0.08); --color-destructive: #EF4444; } body { font-family: 'Inter', ui-sans-serif, system-ui, sans-serif; background: #0A0A0F; color: rgba(255,255,255,0.9); } `}</style> </head> <body class="min-h-screen antialiased"> {children} </body> </html> )
Tailwind v4 ships a browser CDN build that processes classes in the browser — perfect for Workers where we can't run a build step for CSS.
Card, Button, Input, and others
We build a set of reusable components following a consistent dark theme. Here are a few:
// src/components/card.tsx export const Card: FC<{ class?: string; children?: any }> = ({ class: cn, children }) => ( <div class={`rounded-xl border border-white/[0.06] bg-[#12121A] shadow-lg shadow-black/30 ${cn || ''}`}> {children} </div> ) export const CardHeader: FC<{ class?: string; children?: any }> = ({ class: cn, children }) => ( <div class={`flex flex-col gap-1.5 px-6 pt-6 pb-4 ${cn || ''}`}>{children}</div> ) export const CardTitle: FC<{ children?: any }> = ({ children }) => ( <h3 class="text-lg font-semibold tracking-tight text-white/90">{children}</h3> ) export const CardDescription: FC<{ children?: any }> = ({ children }) => ( <p class="text-sm text-[#8B8FA3]">{children}</p> ) export const CardContent: FC<{ class?: string; children?: any }> = ({ class: cn, children }) => ( <div class={`px-6 pb-6 pt-0 ${cn || ''}`}>{children}</div> )
// src/components/button.tsx type ButtonProps = { type?: 'button' | 'submit' | 'reset' variant?: 'primary' | 'ghost' | 'outline' children?: any } const variants = { primary: 'bg-[#2563EB] text-white hover:bg-[#2563EB]/90 shadow-md shadow-black/20', outline: 'border border-white/10 bg-transparent text-foreground/80 hover:bg-[#2563EB]/10 hover:text-[#2563EB] hover:border-[#2563EB]/30', ghost: 'text-muted-foreground hover:text-foreground hover:bg-white/5', } export const Button: FC<ButtonProps> = ({ type = 'button', variant = 'primary', children }) => ( <button type={type} class={`inline-flex items-center justify-center gap-2 rounded-lg text-sm font-medium transition-all duration-150 h-10 px-5 py-2 ${variants[variant]}`} > {children} </button> )
// src/components/input.tsx type InputProps = { label: string name: string type?: string placeholder?: string required?: boolean value?: string readonly?: boolean } export const Input: FC<InputProps> = ({ label, name, type = 'text', placeholder, required, value, readonly }) => ( <div> <label for={name} class="text-sm font-medium text-foreground/80 block mb-3"> {label} </label> <input id={name} name={name} type={type} placeholder={placeholder} required={required} value={value ?? ''} readonly={readonly || undefined} class="h-11 w-full rounded-lg border bg-white/[0.04] px-4 py-2.5 text-sm transition-all duration-150 border-[rgba(255,255,255,0.1)] focus:border-[#2563EB] focus:outline-none focus:ring-2 focus:ring-[#2563EB]/30" /> </div> )
The CompanyCard component displays each registered Cloudinary account with copy-to-clipboard, edit, and delete actions:
// src/components/company-card.tsx function maskMiddle(value: string, visible: number = 6): string { if (value.length <= visible) return value return value.slice(0, visible) + '••••••' } export const CompanyCard: FC<CompanyCardProps> = ({ companyId, cloudName, apiKey }) => ( <div class="flex items-center gap-4 rounded-lg border border-white/[0.06] bg-[#12121A] px-4 py-3"> <span class="inline-flex items-center rounded-md bg-[#2563EB]/10 px-2 py-0.5 text-xs font-medium text-[#2563EB]"> ACTIVE </span> <div class="flex items-center gap-2 min-w-0 flex-1"> <span class="text-xs font-medium text-[#8B8FA3] uppercase tracking-wider">Company ID</span> <code class="font-mono text-sm text-white/90 truncate">{companyId}</code> <button onclick={`navigator.clipboard.writeText('${companyId}')`} title="Copy"> {/* clipboard icon */} </button> </div> <span class="text-sm text-white/90 truncate max-w-[120px]">{cloudName}</span> <code class="font-mono text-sm text-white/60">{maskMiddle(apiKey)}</code> <a href={`/?edit=${companyId}`} title="Edit">{/* edit icon */}</a> <form action={`/delete-tenant/${companyId}`} method="post" onsubmit="return confirm('Remove this account?')"> <button type="submit" title="Delete">{/* trash icon */}</button> </form> </div> )
The CodeBlock component renders syntax-highlighted code examples with a copy button — used by the developer guide page.
Step 8: Dashboard views
The Dashboard view
The dashboard page has two sections: a registration form and a list of registered Cloudinary accounts.
// src/views/dashboard.tsx const RegisterForm: FC<{ editing?: EditingTenant }> = ({ editing }) => ( <Card> <CardHeader> <CardTitle>{editing ? 'Edit Account Credentials' : 'Add Account Credentials'}</CardTitle> <CardDescription> {editing ? 'Update the Cloudinary credentials for this account.' : 'Register a new account by providing their Cloudinary account details.'} </CardDescription> </CardHeader> <CardContent> <form action="/register" method="post" class="grid grid-cols-1 md:grid-cols-2 gap-x-5 gap-y-4"> <Input label="Account UUID / ID" name="companyId" placeholder="e.g., c8392b1a-8291-4bcf" value={editing?.companyId} readonly={!!editing} required /> <Input label="Cloudinary Cloud Name" name="cloudName" placeholder="e.g., petracore-assets" value={editing?.cloudName} required /> <Input label="Cloudinary API Key" name="apiKey" placeholder="e.g., 492819381928392" value={editing?.apiKey} required /> <Input label="Cloudinary API Secret" name="apiSecret" type="password" placeholder={editing ? 'Leave blank to keep current' : 'Enter your API secret'} required={!editing} value={editing?.apiSecret} /> <div class="md:col-span-2 flex items-center justify-between gap-3 pt-2 border-t border-border mt-1"> <p class="text-xs text-muted-foreground"> {editing ? 'Fields left blank will keep their current values.' : 'Credentials are encrypted at rest in Cloudflare KV.'} </p> {editing && <a href="/" class="text-xs text-[#8B8FA3] hover:text-white/90 transition-colors">Cancel</a>} <Button type="submit">{editing ? 'Update Credentials' : 'Save Credentials'}</Button> </div> </form> </CardContent> </Card> )
The empty state shows when no accounts exist:
const EmptyState: FC = () => ( <div class="col-span-full flex flex-col items-center justify-center rounded-xl border-2 border-dashed border-white/[0.06] py-16 px-6 text-center"> <h3 class="text-sm font-semibold text-white/90">No accounts registered</h3> <p class="mt-1 text-sm text-[#8B8FA3]">Add your first account above to get started.</p> </div> )
The Developer Guide view
The guide page is a comprehensive API reference and integration guide, all rendered server-side in JSX. It explains the two-step upload process with code examples for vanilla JavaScript and React. The guide is available at /guide.
Step 9: Dashboard routes
The dashboard routes handle listing Cloudinary accounts, registering new ones, editing, deletion, and serving the guide page.
// src/routes/dashboard.tsx const dashboard = new Hono<{ Bindings: Bindings }>() async function listTenants(env: Bindings) { const list = await env.TENANTS.list() const rows: { companyId: string; cloudName: string; apiKey: string }[] = [] for (const key of list.keys) { const raw = await env.TENANTS.get(key.name) if (!raw) continue const data = JSON.parse(raw) as TenantData rows.push({ companyId: key.name, cloudName: data.cloudName, apiKey: data.apiKey }) } return rows } dashboard.get('/', async (c) => { const rows = await listTenants(c.env) const editId = c.req.query('edit') if (editId) { const raw = await c.env.TENANTS.get(editId) if (raw) { const data = JSON.parse(raw) as TenantData return c.html(<Dashboard rows={rows} editing={{ companyId: editId, cloudName: data.cloudName, apiKey: data.apiKey, apiSecret: data.apiSecret }} />) } } return c.html(<Dashboard rows={rows} />) }) dashboard.post('/register', async (c) => { const body = await c.req.parseBody() const { companyId, cloudName, apiKey, apiSecret } = body if (!companyId || !cloudName || !apiKey) { return c.text('Bad Request: companyId, cloudName, and apiKey are required', 400) } await c.env.TENANTS.put(companyId.trim(), JSON.stringify({ cloudName: cloudName.trim(), apiKey: apiKey.trim(), apiSecret: apiSecret ? apiSecret.trim() : '' } satisfies TenantData)) return c.redirect('/') }) dashboard.post('/delete-tenant/:companyId', async (c) => { const companyId = c.req.param('companyId') await c.env.TENANTS.delete(companyId) return c.redirect('/') }) dashboard.get('/guide', (c) => c.html(<Guide />))
Key points:
listTenantsiterates all KV keys, fetches each value, and parses the JSON- The edit flow passes the account ID as a
?edit=query parameter — the form is pre-populated - Secrets can be left blank during editing to keep the existing value
- Deletion is a POST to
/delete-tenant/:companyIdwith a confirm dialog
Step 10: API routes
The API has two endpoints: /api/sign and /api/delete.
// src/routes/api.ts const api = new Hono<{ Bindings: Bindings }>() api.post('/sign', async (c) => { const jsonBody = await c.req.json<Record<string, string>>() const { company_id, ...uploadParams } = jsonBody if (!company_id) { return c.json({ error: 'Missing company_id parameter' }, 400) } const tenantDataRaw = await c.env.TENANTS.get(company_id) if (!tenantDataRaw) { return c.json({ error: `Company metadata not found for ID: ${company_id}` }, 404) } const { cloudName, apiKey, apiSecret } = JSON.parse(tenantDataRaw) as TenantData const { signature, timestamp } = await generateSignature(uploadParams, apiSecret) const response: SignResponse = { signature, timestamp, api_key: apiKey, cloud_name: cloudName } if (uploadParams.upload_preset) { response.upload_preset = uploadParams.upload_preset } return c.json(response) }) api.post('/delete', async (c) => { const { company_id, public_id, resource_type } = await c.req.json() if (!company_id) return c.json({ error: 'Missing company_id parameter' }, 400) if (!public_id) return c.json({ error: 'Missing public_id parameter' }, 400) const tenantDataRaw = await c.env.TENANTS.get(company_id) if (!tenantDataRaw) { return c.json({ error: `Company metadata not found for ID: ${company_id}` }, 404) } const credentials = JSON.parse(tenantDataRaw) as TenantData const result = await destroyAsset(credentials, public_id, resource_type ?? 'image') return c.json(result, result.ok ? 200 : 502) })
The /api/sign endpoint:
- Extracts
company_idfrom the request body - Looks up the account's credentials from KV
- Generates a SHA-1 signature using Cloudinary's signing algorithm
- Returns
signature,timestamp,api_key, andcloud_name
The client then uses these values to POST the file directly to Cloudinary's upload API.
The /api/delete endpoint:
- Accepts
company_id,public_id, and optionalresource_type - Looks up credentials, signs the destroy request
- Proxies the call to Cloudinary's destroy API
Step 11: Wire it all together
The main entry point ties everything together:
// src/index.ts const app = new Hono<{ Bindings: Bindings }>() // CORS only for API routes app.use('/api/*', apiCors) app.route('/api', api) // Auth only for dashboard routes dashboard.use('/*', basicAuth) app.route('/', dashboard) export default app
The middleware order ensures:
- API routes get CORS headers but no auth
- Dashboard routes get auth (if
AUTH_PASSWORDis set) but no CORS headers - The dashboard and API are on the same worker, deployed together
Step 12: setting up the database (KV)
Cloudflare KV is a global, low-latency key-value store. For this project, we use one KV namespace called TENANTS where each key is an account UUID and the value is a JSON blob:
{ "cloudName": "petracore-assets", "apiKey": "492819381928392", "apiSecret": "abc123secret" }
KV operations used:
TENANTS.put(key, value)— Create or update a tenantTENANTS.get(key)— Retrieve a tenant's credentialsTENANTS.delete(key)— Remove a tenantTENANTS.list()— List all tenant keys
KV is eventually consistent, but for a credential manager where updates are infrequent, this is perfectly fine.
Step 13: Deploying to Cloudflare Workers
Local development
npm run dev
This starts wrangler dev on http://localhost:8787. KV is emulated by Miniflare, so you don't need a real KV namespace for local work.
Production deployment
Set the KV namespace ID in wrangler.jsonc (the one from Step 2):
"kv_namespaces": [ { "binding": "TENANTS", "id": "your-production-kv-id", } ]
Then deploy:
npm run deploy
If you want password-protect the dashboard in production:
npx wrangler secret put AUTH_PASSWORD
Step 14: CI/CD with GitHub Actions
Automating deployment ensures every push to main gets tested and deployed.
# .github/workflows/ci-cd.yml name: CI / CD on: push: branches: [main] jobs: ci: name: Check & Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 22 cache: npm - run: npm ci - run: npm run typecheck - run: npm test deploy: name: Deploy to Cloudflare Workers if: github.ref == 'refs/heads/main' needs: ci runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 22 cache: npm - run: npm ci - name: Inject KV namespace ID run: > sed -i 's/PLACEHOLDER_KV_ID/${{ secrets.PROD_KV_ID }}/' wrangler.jsonc - name: Deploy uses: cloudflare/wrangler-action@v3 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
GitHub secrets you need:
The sed step replaces the placeholder KV ID in wrangler.jsonc with the real production ID from secrets before deploying.
Step 15: Using the API from a frontend
Upload flow
async function handleUpload(file: File, companyId: string) { // Step 1: Get a signature const { signature, timestamp, api_key, cloud_name } = await fetch('/api/sign', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ company_id: companyId, folder: 'uploads' }) }).then(r => r.json()) // Step 2: Upload directly to Cloudinary const form = new FormData() form.append('file', file) form.append('api_key', api_key) form.append('timestamp', timestamp) form.append('signature', signature) form.append('folder', 'uploads') return fetch(`https://api.cloudinary.com/v1_1/${cloud_name}/auto/upload`, { method: 'POST', body: form }).then(r => r.json()) }
Delete flow
async function deleteAsset(publicId: string, companyId: string) { const res = await fetch('/api/delete', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ company_id: companyId, public_id: publicId }) }) return res.json() }
Both endpoints work from any framework — React, Vue, Svelte, or vanilla JS. The files never pass through the worker, so there's no bandwidth cost or size limit beyond what Cloudinary enforces.
Project structure
Here's the final file layout:
petra-cloudinary-worker/
├── .dev.vars.example # Local env vars template
├── .github/
│ └── workflows/
│ └── ci-cd.yml # GitHub Actions pipeline
├── blog/ # This blog post
├── package.json
├── tsconfig.json
├── wrangler.jsonc # Cloudflare Workers config
└── src/
├── index.ts # Entry point, routes wiring
├── types.ts # Shared TypeScript types
├── middleware/
│ ├── auth.ts # HTTP Basic Auth middleware
│ └── cors.ts # CORS middleware
├── utils/
│ ├── cloudinary.ts # Signature generation, destroy
│ └── cloudinary.test.ts
├── routes/
│ ├── api.ts # /api/sign, /api/delete endpoints
│ └── dashboard.tsx # Dashboard routes (CRUD accounts)
├── views/
│ ├── dashboard.tsx # Dashboard page JSX
│ └── guide.tsx # Developer guide page JSX
└── components/
├── button.tsx # Button component
├── card.tsx # Card with header/content
├── code-block.tsx # Syntax-highlighted code block
├── company-card.tsx # Account row component
├── input.tsx # Form input component
├── layout.tsx # HTML shell + Tailwind
└── table.tsx # Table component (unused currently)
Security considerations
-
API secrets in KV — Cloudinary API secrets are stored as plain JSON in KV. Cloudflare encrypts KV data at rest, but for production, consider encrypting secrets with per-account keys before storing them.
-
Dashboard auth — HTTP Basic Auth is simple but sends the password in cleartext (base64 encoded) with every request. In production, use HTTPS (Cloudflare Workers provides this by default) and consider upgrading to Cloudflare Access or a JWT-based auth flow.
-
No rate limiting — The signing endpoint doesn't limit requests. A malicious client could request many signatures. Consider adding rate limiting via Cloudflare's Rate Limiting product or a KV-based counter.
-
No input validation — Request bodies are not validated. Use Zod or a similar library to validate inputs and provide meaningful error messages.
Conclusion
We built a production-ready Cloudinary signing proxy on Cloudflare Workers in less than 500 lines of TypeScript. The entire application — dashboard UI, API, and auth — runs at the edge with no backend servers, no cold starts, and zero infrastructure management.
The full source code is available in the repository. Clone it, set up your KV namespace, and deploy with a single command. Happy building!





