Skip to main content

Overview

Desktop cloud fallback is gated on a WORLDMONITOR_API_KEY. Without a valid key, the desktop app operates local-only (sidecar). A registration form collects emails via Convex DB for future key distribution.

Architecture

Required Environment Variables

Vercel

Generating API keys

Keys must be at least 16 characters (validated client-side). Recommended format:
Add to WORLDMONITOR_VALID_KEYS in Vercel dashboard (comma-separated, no spaces).

Convex Setup

First-time deployment

Verify Convex deployment

Schema

The registrations table stores: Indexed by normalizedEmail for duplicate detection.

Security Model

Client-side (desktop app)

  • installRuntimeFetchPatch() checks WORLDMONITOR_API_KEY before allowing cloud fallback
  • Key must be present AND valid (min 16 chars)
  • secretsReady promise ensures secrets are loaded before first fetch (2s timeout)
  • Fail-closed: any error in key check blocks cloud fallback

Server-side (Vercel edge)

  • api/_api-key.js validates X-WorldMonitor-Key header on sebuf routes
  • Origin-aware: desktop origins (tauri.localhost, tauri://, asset://) require a key
  • Web origins (worldmonitor.app) pass through without a key
  • Non-desktop origin with key header: key is still validated
  • Invalid key returns 401 { error: "Invalid API key" }

CORS

X-WorldMonitor-Key is allowed in both server/cors.ts and api/_cors.js.

Local Vercel env dumps

Do not keep Vercel env exports in the repository root. .env.vercel-backup and .env.vercel-export are ignored by Git, but they are still plaintext production secret dumps that local tools, editor agents, backup software, or dependency install scripts can read. The pre-push hook fails when either file exists. Pull environment values only when needed, work from a short-lived local env file, and delete the file after use. Secret rotation and deletion from developer machines are operational tasks; rotate exposed keys through the owning vendor dashboards, prioritizing LLM, payment, auth, Redis, and Convex credentials.

Verification Checklist

After deployment:
  • Set WORLDMONITOR_VALID_KEYS in Vercel
  • Set CONVEX_URL in Vercel
  • Run npx convex deploy to push schema
  • Desktop without key: cloud fallback blocked (console shows cloud fallback blocked)
  • Desktop with invalid key: sebuf requests get 401
  • Desktop with valid key: cloud fallback works as before
  • Web access: no key required, works normally
  • Registration form: submit email, check Convex dashboard
  • Duplicate email: shows “already registered”
  • Existing settings tabs (LLMs, API Keys, Debug) unchanged

Files Reference