Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/stream/configuration.md
1# Stream Configuration23Setup, environment variables, and wrangler configuration.45## Installation67```bash8# Official Cloudflare SDK (Node.js, Workers, Pages)9npm install cloudflare1011# React component library12npm install @cloudflare/stream-react1314# TUS resumable uploads (large files)15npm install tus-js-client16```1718## Environment Variables1920```bash21# Required22CF_ACCOUNT_ID=your-account-id23CF_API_TOKEN=your-api-token2425# For signed URLs (high volume)26STREAM_KEY_ID=your-key-id27STREAM_JWK=base64-encoded-jwk2829# For webhooks30WEBHOOK_SECRET=your-webhook-secret3132# Customer subdomain (from dashboard)33STREAM_CUSTOMER_CODE=your-customer-code34```3536## Wrangler Configuration3738```jsonc39{40"name": "stream-worker",41"main": "src/index.ts",42"compatibility_date": "2025-01-01", // Use current date for new projects43"vars": {44"CF_ACCOUNT_ID": "your-account-id"45}46// Store secrets: wrangler secret put CF_API_TOKEN47// wrangler secret put STREAM_KEY_ID48// wrangler secret put STREAM_JWK49// wrangler secret put WEBHOOK_SECRET50}51```5253## Signing Keys (High Volume)5455Create once for self-signing tokens (thousands of daily users).5657**Create key**58```bash59curl -X POST \60"https://api.cloudflare.com/client/v4/accounts/{account_id}/stream/keys" \61-H "Authorization: Bearer <API_TOKEN>"6263# Save `id` and `jwk` (base64) from response64```6566**Store in secrets**67```bash68wrangler secret put STREAM_KEY_ID69wrangler secret put STREAM_JWK70```7172## Webhooks7374**Setup webhook URL**75```bash76curl -X PUT \77"https://api.cloudflare.com/client/v4/accounts/{account_id}/stream/webhook" \78-H "Authorization: Bearer <API_TOKEN>" \79-H "Content-Type: application/json" \80-d '{"notificationUrl": "https://your-worker.workers.dev/webhook"}'8182# Save the returned `secret` for signature verification83```8485**Store secret**86```bash87wrangler secret put WEBHOOK_SECRET88```8990## Direct Upload / Live / Watermark Config9192```typescript93// Direct upload94const uploadConfig = {95maxDurationSeconds: 3600,96expiry: new Date(Date.now() + 3600000).toISOString(),97requireSignedURLs: true,98allowedOrigins: ['https://yourdomain.com'],99meta: { creator: 'user-123' }100};101102// Live input103const liveConfig = {104recording: { mode: 'automatic', timeoutSeconds: 30 },105deleteRecordingAfterDays: 30106};107108// Watermark109const watermark = {110name: 'Logo', opacity: 0.7, padding: 20,111position: 'lowerRight', scale: 0.15112};113```114115## Access Rules & Player Config116117```typescript118// Access rules: allow US/CA, block CN/RU, or IP allowlist119const geoRestrict = [120{ type: 'ip.geoip.country', action: 'allow', country: ['US', 'CA'] },121{ type: 'any', action: 'block' }122];123124// Player params for iframe125const playerParams = new URLSearchParams({126autoplay: 'true', muted: 'true', preload: 'auto', defaultTextTrack: 'en'127});128```129130## In This Reference131132- [README.md](./README.md) - Overview and quick start133- [api.md](./api.md) - On-demand video APIs134- [api-live.md](./api-live.md) - Live streaming APIs135- [patterns.md](./patterns.md) - Full-stack flows, best practices136- [gotchas.md](./gotchas.md) - Error codes, troubleshooting137138## See Also139140- [wrangler](../wrangler/) - Wrangler CLI and configuration141- [workers](../workers/) - Deploy Stream APIs in Workers142