Give /api/org/current the domain the client requires

Fixkamo-internal
Shipped
August 24, 2026 at 10:15 PM UTC
Author
kamo
Commit
521d917

internal.kamocrm.com failed to render with "Invalid organization data: missing 'id' or 'domain'". Organization.fromJSON refuses a record without a domain, and the Organization entity does not carry one -- it has a `domains` collection. The by-host route injects the host it was asked about (route.ts:577); /api/org/current had no host to inject and returned the upstream JSON verbatim, so `domain` was undefined and the shell threw before it rendered. The domain is now derived: the org's own active top-level row when it has one, otherwise {alias}.kamocrm.com -- the same fallback SecurityService uses to name the org's theme folder, so branding resolves to the same place from both sides. Alias rows are skipped; they hold a bare label, not a hostname. When nothing can be derived the route 404s rather than return a record the client will throw on, and the layout falls back to the host lookup as it already does for a signed-out visitor. 2873 tests pass.

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing