Files
supabase/apps/studio/hooks
Alaister Young 5c9d3209de feat(studio): session-scoped Vercel skew protection for the TanStack SPA
Pin each browser session to the deployment that served it, so a long-lived
dashboard session never 404s on a lazily-loaded chunk or changes version
mid-session. Session cookie (no expiry) → next visit gets latest.

- vite.config: inline VERCEL_DEPLOYMENT_ID + VERCEL_SKEW_PROTECTION_ENABLED.
- router.tsx (TanStack-only): set a session __vdpl cookie scoped to BASE_PATH
  on client boot (platform + skew-enabled only); plus a vite:preloadError
  backstop that clears the pin and reloads if a chunk 404s (e.g. the pinned
  deployment aged out), with a time-window guard against reload loops.
- deployment-commit-query: fetch the version-check endpoint with
  credentials:'omit' so the __vdpl cookie isn't sent and the edge serves the
  LATEST deployment — the update popup keeps detecting new versions while the
  session stays pinned. Stays on the basePath URL (root /api is the marketing
  site in prod).
- use-check-latest-deploy: the Refresh button clears __vdpl before reloading
  so it lands on latest (no-op on the Next build, which sets no cookie).

Requires enabling Skew Protection + System Env Vars in the Vercel project, and
a Maximum Age comfortably above typical session length.
2026-06-19 14:48:14 +08:00
..