Skip to content

Commit 60d540b

Browse files
committed
chore(deps): upgrade next.js to 16.2.4
- Bump next and @next/env to 16.2.4 across root, apps/sim, apps/docs - Replace next-runtime-env's env() helper (calls unstable_noStore(), rejected by Next 16.2 outside request scope) with a direct window.__ENV / process.env getter - Add export const dynamic = 'force-dynamic' on landing /privacy and /terms pages so NEXT_PUBLIC_* runtime env reads aren't baked at build
1 parent 0925e2d commit 60d540b

8 files changed

Lines changed: 47 additions & 30 deletions

File tree

apps/docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"fumadocs-openapi": "10.3.13",
2727
"fumadocs-ui": "16.6.7",
2828
"lucide-react": "^0.511.0",
29-
"next": "16.1.6",
29+
"next": "16.2.4",
3030
"next-themes": "^0.4.6",
3131
"postgres": "^3.4.5",
3232
"react": "19.2.4",

apps/sim/app/(landing)/privacy/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import Link from 'next/link'
33
import { getEnv } from '@/lib/core/config/env'
44
import { ExternalRedirect, LegalLayout } from '@/app/(landing)/components'
55

6+
/** Opt out of static prerendering so `NEXT_PUBLIC_PRIVACY_URL` is read from
7+
* the live runtime environment (e.g. Docker-injected) rather than baked at build. */
8+
export const dynamic = 'force-dynamic'
9+
610
export const metadata: Metadata = {
711
title: 'Privacy Policy',
812
description:

apps/sim/app/(landing)/terms/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import Link from 'next/link'
33
import { getEnv } from '@/lib/core/config/env'
44
import { ExternalRedirect, LegalLayout } from '@/app/(landing)/components'
55

6+
/** Opt out of static prerendering so `NEXT_PUBLIC_TERMS_URL` is read from
7+
* the live runtime environment (e.g. Docker-injected) rather than baked at build. */
8+
export const dynamic = 'force-dynamic'
9+
610
export const metadata: Metadata = {
711
title: 'Terms of Service',
812
description:

apps/sim/lib/core/config/env.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
import { createEnv } from '@t3-oss/env-nextjs'
2-
import { env as runtimeEnv } from 'next-runtime-env'
32
import { z } from 'zod'
43

54
/**
65
* Universal environment variable getter that works in both client and server contexts.
7-
* - Client-side: Uses next-runtime-env for runtime injection (supports Docker runtime vars)
8-
* - Server-side: Falls back to process.env when runtimeEnv returns undefined
9-
* - Provides seamless Docker runtime variable support for NEXT_PUBLIC_ vars
6+
* - Client-side: reads from `window.__ENV`, which `<PublicEnvScript>` from
7+
* next-runtime-env populates before hydration (declared globally by that
8+
* package). Supports Docker runtime injection of `NEXT_PUBLIC_*` vars
9+
* without rebuilding.
10+
* - Server-side: reads `process.env` directly.
11+
*
12+
* We deliberately do not import next-runtime-env's `env()` helper. It calls
13+
* `unstable_noStore()` from `next/cache`, which Next 16.2+ rejects when
14+
* invoked outside a request scope (e.g. during `next.config.ts` compilation
15+
* or top-level module evaluation).
1016
*/
11-
const getEnv = (variable: string) => runtimeEnv(variable) ?? process.env[variable]
17+
const getEnv = (variable: string): string | undefined => {
18+
if (typeof window === 'undefined') return process.env[variable]
19+
return window.__ENV?.[variable] ?? process.env[variable]
20+
}
1221

1322
// biome-ignore format: keep alignment for readability
1423
export const env = createEnv({

apps/sim/next.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { NextConfig } from 'next'
2-
import { env, getEnv, isTruthy } from './lib/core/config/env'
2+
import { env, isTruthy } from './lib/core/config/env'
33
import { isDev } from './lib/core/config/feature-flags'
44
import {
55
getChatEmbedCSPPolicy,
@@ -40,13 +40,13 @@ const nextConfig: NextConfig = {
4040
hostname: 'lh3.googleusercontent.com',
4141
},
4242
// Brand logo domain if configured
43-
...(getEnv('NEXT_PUBLIC_BRAND_LOGO_URL')
43+
...(process.env.NEXT_PUBLIC_BRAND_LOGO_URL
4444
? (() => {
4545
try {
4646
return [
4747
{
4848
protocol: 'https' as const,
49-
hostname: new URL(getEnv('NEXT_PUBLIC_BRAND_LOGO_URL')!).hostname,
49+
hostname: new URL(process.env.NEXT_PUBLIC_BRAND_LOGO_URL!).hostname,
5050
},
5151
]
5252
} catch {
@@ -55,13 +55,13 @@ const nextConfig: NextConfig = {
5555
})()
5656
: []),
5757
// Brand favicon domain if configured
58-
...(getEnv('NEXT_PUBLIC_BRAND_FAVICON_URL')
58+
...(process.env.NEXT_PUBLIC_BRAND_FAVICON_URL
5959
? (() => {
6060
try {
6161
return [
6262
{
6363
protocol: 'https' as const,
64-
hostname: new URL(getEnv('NEXT_PUBLIC_BRAND_FAVICON_URL')!).hostname,
64+
hostname: new URL(process.env.NEXT_PUBLIC_BRAND_FAVICON_URL!).hostname,
6565
},
6666
]
6767
} catch {

apps/sim/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
"mongodb": "6.19.0",
161161
"mysql2": "3.14.3",
162162
"neo4j-driver": "6.0.1",
163-
"next": "16.1.6",
163+
"next": "16.2.4",
164164
"next-mdx-remote": "^5.0.0",
165165
"next-runtime-env": "3.3.0",
166166
"next-themes": "^0.4.6",
@@ -250,8 +250,8 @@
250250
"sharp"
251251
],
252252
"overrides": {
253-
"next": "16.1.6",
254-
"@next/env": "16.1.6",
253+
"next": "16.2.4",
254+
"@next/env": "16.2.4",
255255
"drizzle-orm": "^0.45.2",
256256
"postgres": "^3.4.5",
257257
"react-floater": {

bun.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
"overrides": {
4949
"react": "19.2.4",
5050
"react-dom": "19.2.4",
51-
"next": "16.1.6",
52-
"@next/env": "16.1.6",
51+
"next": "16.2.4",
52+
"@next/env": "16.2.4",
5353
"drizzle-orm": "^0.45.2",
5454
"postgres": "^3.4.5"
5555
},

0 commit comments

Comments
 (0)