refactor(api): migrate functions.invoke to Cloudflare API

Merged
RI
3mo ago
+775-196

Summary (AI generated)

  • Route Capgo console supabase.functions.invoke calls through invokeCapgoApi → VITE_API_HOST (api.capgo.app) instead of sb.capgo.app
  • Route Capgo CLI former invoke call sites through invokeCapgoCliApi → hostApi / hostFilesApi (self-host still uses /functions/v1)
  • Shrink Capgo cloud Supabase publish allowlist: keep triggers forever; keep bundle, channel, files, private until 2026-10-28 for older CLIs; stop publishing console-only apikey, app, organization, statistics, webhooks

Motivation (AI generated)

Publishing unused Capgo cloud edge functions is an infra abuse risk. Console and new CLI can talk to Cloudflare directly; old CLIs still hit Supabase invoke for a few endpoints, so those stay published for ~3 months.

Business Impact (AI generated)

Fewer Capgo cloud Supabase functions to operate and attack, without breaking existing customer CLIs during the upgrade window. Self-host full deploy is unchanged.

Test Plan (AI generated)

  • Console: open API keys, webhooks, Stripe portal/checkout, org invites, password compliance — confirm requests go to api.capgo.app, not sb.capgo.app/functions/v1
  • CLI latest: bundle upload, channel set/delete, upload link / delete failed version / set manifest against Capgo cloud
  • CLI with --supa-host / self-host: same flows still hit /functions/v1
  • Capgo cloud deploy only publishes allowlisted functions (bun scripts/supabase-cloud-functions.ts list)
  • Unit: bunx vitest run tests/supabase-cloud-functions.unit.test.ts
  • After 2026-10-28: remove bundle/channel/files/private from the allowlist and delete Capgo cloud Supabase deployments

Generated with AI

Made with Cursor

Summary by CodeRabbit

  • New Features

    • Added unified API routing for cloud, self-hosted, and local deployments.
    • Standardized dashboard, onboarding, billing, webhooks, access control, and account operations.
    • Improved support for configurable hosts and authentication.
  • Deployment

    • Cloud deployments now publish approved functions and remove obsolete ones.
    • Added safeguards when no deployable functions are available.
  • Documentation

    • Clarified cloud and self-hosted deployment behavior, routing, and migration timelines.
  • Tests

    • Added coverage for deployment allowlists and API integration updates.