mirror of
https://github.com/bitbaum/orangecat.git
synced 2026-12-04 04:57:19 +01:00
* docs: archive point-in-time records, drop broken guide symlinks Status reports, progress trackers, audits, session summaries, completed migration plans and the 2025 roadmap move to docs/archive/ (same relative path), with a README saying they describe the day they were written. .ai-guides/ held only symlinks into a docs/guides/ai/ that no longer exists, tests/unit/docs/ held a stray copy of an old getting-started page, and docs/operations/PORT_MANAGEMENT_README.md duplicated port-management.md; all three are deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJkbo18cRNXtgPWZN2S9cD * docs: correct drifted paths, links and versions in current docs Fix in place the reference docs agents use: point paths at where the code lives now (src/stores/auth.ts, src/lib/supabase/*, scripts/dev/*, docs/reference/api/CONVENTIONS.md, the squashed baseline migration), rewrite the development, features, operations and API index pages to list documents that exist, say plainly where something is gone (/api/metrics, the CSP report route, .envrc in the repo, Loki's `migrate` script), and correct the Next.js major. docs-truth findings: 468 -> 2 (both "Next 30/90 Days" headings in the legal overview, a checker false positive). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJkbo18cRNXtgPWZN2S9cD --------- Co-authored-by: Claude <noreply@anthropic.com>
2.4 KiB
2.4 KiB
Supabase Connectivity
Environment
- Required (all environments):
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEY
- Optional (server-side admin only):
SUPABASE_SERVICE_ROLE_KEY(do not expose publicly)
Runtime Clients
- Browser:
src/lib/supabase/browser.ts(uses anon key, lazy validates env). - Server:
src/lib/supabase/server.ts(SSR client using anon key + cookies for session handling). - Admin:
src/lib/supabase/admin.ts(service-role client; falls back to a dummy that throws if missing to avoid unsafe usage).
Health Check
GET /api/healthchecks Supabase availability:- Tries admin client if
SUPABASE_SERVICE_ROLE_KEYis present. - Falls back to SSR anon client if admin is absent.
- Performs a minimal
profilesquery withhead: true.
- Tries admin client if
CLI-Free Local Diagnostics
- Run
node scripts/diagnostics/check-supabase.mjsto verify env + connectivity and head-only selects on key tables (profiles,organizations,funding_pages). - Uses
.env.local(if present) and prefersSUPABASE_SERVICE_ROLE_KEYwhen available.
Write Test (optional)
- Run
node scripts/diagnostics/write-test-supabase.jsto 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_pagesrow (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
- Use the remote self-hosted Supabase (
supabase.orangecat.ch) — do not run a local stack. - Set
.env.localwith the required keys (see.env.example). - Run
pnpm run dev(orpnpm run fresh:start). - Verify via
curl http://localhost:3000/api/health.
Production
- Configure envs in
/opt/orangecat/app/.envon the Hetzner box (Production):NEXT_PUBLIC_SUPABASE_URL,NEXT_PUBLIC_SUPABASE_ANON_KEY(required)SUPABASE_SERVICE_ROLE_KEY(optional; only if admin operations are required at runtime)
- Production points at the self-hosted Supabase at
supabase.orangecat.ch.
Troubleshooting
- Missing envs cause a runtime error on first Supabase client usage;
/api/healthwill showsupabaseasdown. - Verify the domain in
NEXT_PUBLIC_SUPABASE_URLand that keys match the target environment (dev/staging/prod).