* fix(auth): unblock the public API surface — login was unreachable in prod
The middleware session-gated ALL of /api, so every anonymous endpoint
307-redirected to the login page: the NextAuth session + credentials
callback (login itself), registration, password reset, the assessment-
leads funnel, and the Calendly webhook. Signed-in traffic looked healthy,
so nothing caught it.
- PUBLIC_API_PREFIXES in lib/config/routes.ts (SSOT) — each listed
prefix authenticates itself (NextAuth, HMAC signature, CRON_SECRET,
or Zod-validated no-PII writes)
- gated /api paths now answer 401 JSON instead of an HTML login page
- new /api/health (fleet convention): 200 = app up + DB reachable
- route-auth-invariant.test.ts pins the class: every route under a
public prefix must self-authenticate; every gated route must import
a guard
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* refactor: delete the dead unlocalized auth tree + audit fixes
next-intl (localePrefix: always) redirects /login -> /de/login, so the
app/(auth) tree never rendered — a full duplicate of the localized auth
pages, drifting separately (hardcoded English, stale styles). Deleted.
Its stylesheet WAS live (portal forms imported it): the shared form
primitives now live once in app/forms.module.css; auth.module.css
re-exports them via composes.
Also from the audit sweep:
- public/robots.txt deleted — it shadowed app/robots.ts, so the
portal/admin/api disallow rules never shipped
- portal nav labels: one SSOT (PORTAL_ROUTE_LABELS) for PortalNav and
NavBreadcrumb — breadcrumb was silently blank on /goals and
/documents because the two copies had drifted
- global 404 now links to the public homepage, not the auth-gated
dashboard
- manifest icons existed only as references: generated icon-192/512.png
from the brand mark (404'd on every page load before)
- Google auth provider only registers when its env is configured
- dead SignOutButton component + create-next-app template SVGs removed
- drop package.json pnpm.onlyBuiltDependencies (moved to
pnpm-workspace.yaml allowBuilds long ago; pnpm warned on every run)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(ui): admin patient page 500, dead mobile CSS, and portal polish
- schema: documents<->users is doubly connected (owner + uploader); the
unnamed primary relation made Drizzle throw at query time and the
admin patient-detail page — the core clinical view — 500'd in prod.
Both sides now carry relationName. lib/db/relations.test.ts plans a
query over EVERY declared relation so the next misconfigured relation
(this was the second) fails in CI, not in prod.
- admin.module.css: the entire mobile @media block sat BEFORE the base
rules it overrides (appended later), so phones got the desktop layout
— 4-across stat tiles clipping their labels, oversized title, no
form-grid collapse. Block moved after its base rules;
lib/css-order.test.ts now fails any stylesheet where a base rule
shadows an earlier @media override.
- proxy: admins landing on /dashboard (post-login default, PWA
start_url) are redirected to /admin/patients — they were dropped into
the empty patient portal.
- check-in scale: hovering the button just clicked painted the number
teal-on-teal (.scaleBtn:hover outranked .scaleBtnActive)
- admin assessment-trend chart plotted newest-first — time axis read
right-to-left; reversed to chronological
- sidebar wordmark was ink-on-ink (only 'Re' visible): Logo gains a
'bright' on-dark variant, used by portal + admin sidebars
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>