Setup
1. Deploy Worker
cd worker npm install wrangler kv namespace create KV # copy ID into wrangler.toml wrangler secret put YOUTUBE_CLIENT_ID wrangler secret put YOUTUBE_CLIENT_SECRET wrangler secret put ALARM_SECRET # any random string wrangler secret put API_KEY # any random string wrangler deploy
2. Connect YouTube
Create a Google Cloud project → enable YouTube Data API v3 → OAuth 2.0 credentials (Web app).
Add https://vigi-vms-worker.anonnaabir.workers.dev/setup/callback as an authorised redirect URI.
3. Configure VIGI Alarm Server
In VIGI VMS → Camera → Event → Alarm Server → add new server:
Server Address
https://vigi-vms-worker.anonnaabir.workers.dev/alarm/YOUR_ALARM_SECRETPort
443Protocol
HTTPSThen in Motion Detection → Linkage Method → check Send to Alarm Server.
4. Deploy Web App
cd web npm install # Add to Cloudflare Pages env vars: # NEXT_PUBLIC_WORKER_URL = https://YOUR_WORKER.workers.dev # NEXT_PUBLIC_API_KEY = (same as API_KEY secret above) npm run pages:build wrangler pages deploy
Verify
Wave in front of camera → check Worker logs (wrangler tail) → live stream should appear on the home page within ~30 seconds.