Frontend Local Tilt Architecture
This retrospective covers the shift across bf25fc6, 8b28948, 88d7c0a, c7ad439, and 5501704.
Symptoms
- Frontend hydration and HMR were unreliable when
next devran behind cluster ingress. - Frontend iteration speed was coupled to cluster deployment and ingress behavior.
- Local custom-domain checks on
*.localhostfailed for server-side fetches. - Turbopack dev sessions on Apple Silicon could grow memory for hours without stabilizing.
Diagnosis
The current architecture is intentionally local-first:
lumie-frontend/Tiltfileregisterslumie-frontendas alocal_resourcethat runsnpm run dev.lumie-frontend/package.jsondefinesdevas plainnext dev, notnext dev --turbo.lumie-frontend/src/shared/api/resolveBaseUrl.tsloops SSR requests back through the frontend origin and useshttpforlocalhostand*.localhost..github/tilt-up.shstill launches Tilt from the workspace root, so the frontend starts alongside the cluster-backed services without being deployed into the cluster.
Root Cause
The original dev-cluster layout treated the Next.js frontend like another cluster workload. That model fought the actual behavior of next dev:
bf25fc6removed the cluster deployment entirely after repeated hydration deadlocks behind Traefik HTTP/2 ALPN.8b28948restored frontend participation intilt up, but only as a local process on the developer laptop.88d7c0aremoved--turboafter long-running Apple Silicon dev sessions showed unbounded Turbopack memory growth.c7ad439moved non-secret frontend env toTiltfileserve_env, so local dev no longer depended on per-developer.env.localdrift.5501704fixed the remaining SSR edge case:resolveBaseUrl()had treatedfoo.localhostashttps, even thoughnext devserves those hosts overhttp.
Fix
The stable architecture is:
- State-heavy services stay in the cluster.
- The Next.js app runs locally through Tilt-managed
npm run dev. - Browser requests stay same-origin on
http://localhost:3000and go through the frontend/apiproxy toNEXT_PUBLIC_API_BASE. - Local SSR uses the request
Hostheader instead of a forced internal backend URL.
Related proxy-specific auth pitfalls are documented in Next.js API Proxy Auth Gotchas.
Prevention And Verification
- Do not reintroduce
next devas a cluster deployment. The warning is preserved directly inlumie-frontend/Tiltfile. - Verify that
tilt upexposes a locallumie-frontendresource rather than a Kubernetes deployment. - Verify that
lumie-frontend/package.jsonstill usesnext dev. - Verify that
resolveBaseUrl()still maps bothlocalhostand*.localhosttohttp.