mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
next-runtime-env's <PublicEnvScript /> uses next/script beforeInteractive internally. On Next.js error-page shells (<html id="__next_error__">), beforeInteractive is not honored — the env script is serialized into the RSC stream instead of being hoisted as a real <script> in <head>, so it runs after client chunks evaluate. Any module that calls getBaseUrl() at module-eval time (e.g. lib/auth/auth-client.ts) then crashes because window['__ENV'] is still undefined. disableNextScript renders a plain inline <script> in <head> that the browser executes synchronously during HTML parse on every render path, including error pages. Fixes "Application error: a client-side exception" on 404 routes like /models/anthropic/xxx and /integrations/rand. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>