Skip to content

Commit 42ef2b1

Browse files
waleedlatif1claude
andauthored
fix(landing): resolve error-page crash on invalid /models and /integrations routes (#4243)
* fix(layout): use plain inline script for PublicEnvScript to set env before chunks eval on error pages * fix(landing): handle runtime env race on error-page renders React skips SSR on unhandled server errors and re-renders on the client (see vercel/next.js#63980, #82456). Root-layout scripts — including the runtime env script that populates window.__ENV — are inserted but not executed on that client re-render, so any client module that reads env at module evaluation crashes the render into a blank "Application error" overlay instead of rendering the styled 404. This replaces the earlier PublicEnvScript tweak with the architectural fix: - auth-client.ts: fall back to window.location.origin when getBaseUrl() throws on the client. Auth endpoints are same-origin, so this is the correct baseURL on the client. Server-side we still throw on genuine misconfig. - loading.tsx under /models/[provider], /models/[provider]/[model], and /integrations/[slug]: establishes a Suspense boundary below the root layout so a page-level notFound() no longer invalidates the layout's SSR output (the fix endorsed by Next.js maintainers in #63980). - layout.tsx: revert disableNextScript — the research showed this doesn't actually fix error-page renders. The real fix is above. * improvement(landing): use emcn Loader in scoped loading.tsx, trim auth-client comment Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]>
1 parent 2456128 commit 42ef2b1

4 files changed

Lines changed: 37 additions & 1 deletion

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Loader } from '@/components/emcn'
2+
3+
export default function IntegrationDetailLoading() {
4+
return (
5+
<div className='flex min-h-[60vh] items-center justify-center bg-[var(--landing-bg)]'>
6+
<Loader animate className='h-6 w-6 text-[var(--landing-text-muted)]' />
7+
</div>
8+
)
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Loader } from '@/components/emcn'
2+
3+
export default function ModelDetailLoading() {
4+
return (
5+
<div className='flex min-h-[60vh] items-center justify-center bg-[var(--landing-bg)]'>
6+
<Loader animate className='h-6 w-6 text-[var(--landing-text-muted)]' />
7+
</div>
8+
)
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Loader } from '@/components/emcn'
2+
3+
export default function ModelProviderLoading() {
4+
return (
5+
<div className='flex min-h-[60vh] items-center justify-center bg-[var(--landing-bg)]'>
6+
<Loader animate className='h-6 w-6 text-[var(--landing-text-muted)]' />
7+
</div>
8+
)
9+
}

apps/sim/lib/auth/auth-client.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,17 @@ import { isBillingEnabled, isOrganizationsEnabled } from '@/lib/core/config/feat
1515
import { getBaseUrl } from '@/lib/core/utils/urls'
1616
import { SessionContext, type SessionHookResult } from '@/app/_shell/providers/session-provider'
1717

18+
function getAuthBaseUrl(): string {
19+
try {
20+
return getBaseUrl()
21+
} catch (e) {
22+
if (typeof window !== 'undefined') return window.location.origin
23+
throw e
24+
}
25+
}
26+
1827
export const client = createAuthClient({
19-
baseURL: getBaseUrl(),
28+
baseURL: getAuthBaseUrl(),
2029
plugins: [
2130
adminClient(),
2231
emailOTPClient(),

0 commit comments

Comments
 (0)