Files
orangecat/docs/devops/supabase.md
T
Your NameandClaude 2872828779 chore: version 0.1.1 deployment - fix configuration and dependencies
- Bump version to 0.1.1 for tracking
- Add webpack-bundle-optimizer script for Next.js config
- Simplify ESLint configuration to resolve missing dependencies
- Prepare for production deployment with proper version control

This deployment includes:
- Profile update fixes with banner_url support
- LN address validation
- Auth cookie fixes for profile updates
- Various documentation and testing improvements

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-13 09:30:45 +02:00

2.3 KiB

Supabase Connectivity

Environment

  • Required (all environments):
    • NEXT_PUBLIC_SUPABASE_URL
    • NEXT_PUBLIC_SUPABASE_ANON_KEY
  • Optional (server-side admin only):
    • SUPABASE_SERVICE_ROLE_KEY (do not expose publicly)

Runtime Clients

  • Browser: src/services/supabase/client.ts (uses anon key, lazy validates env).
  • Server: src/services/supabase/server.ts (SSR client using anon key + cookies for session handling).
  • Admin: src/services/supabase/admin.ts (service-role client; falls back to a dummy that throws if missing to avoid unsafe usage).

Health Check

  • GET /api/health checks Supabase availability:
    • Tries admin client if SUPABASE_SERVICE_ROLE_KEY is present.
    • Falls back to SSR anon client if admin is absent.
    • Performs a minimal profiles query with head: true.

CLI-Free Local Diagnostics

  • Run npm run diag:supabase to verify env + connectivity and head-only selects on key tables (profiles, organizations, funding_pages).
  • Uses .env.local (if present) and prefers SUPABASE_SERVICE_ROLE_KEY when available.

Write Test (optional)

  • Run npm run diag:supabase:write to perform a safe end-to-end write test:
    • Creates a temporary auth user via Admin API (service-role required)
    • Ensures a profile exists (trigger or fallback insert)
    • Inserts a temporary funding_pages row (if owner column detected), then deletes it
    • Cleans up by deleting the temporary auth user (cascades to profile)
  • No existing data is modified; temporary records are removed at the end.

Local Development

  1. Start Supabase locally (Supabase CLI) or use hosted project.
  2. Set .env.local with the required keys (see .env.example).
  3. Run npm run dev (or npm run fresh:start).
  4. Verify via curl http://localhost:3000/api/health.

Production

  • Configure envs in Vercel Project settings (Production/Preview):
    • NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_ANON_KEY (required)
    • SUPABASE_SERVICE_ROLE_KEY (optional; only if admin operations are required at runtime)
  • CI workflow uses GitHub Secrets for Vercel credentials only.

Troubleshooting

  • Missing envs cause a runtime error on first Supabase client usage; /api/health will show supabase as down.
  • Verify the domain in NEXT_PUBLIC_SUPABASE_URL and that keys match the target environment (dev/staging/prod).