Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions crates/next-build-test/nextConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
"productionBrowserSourceMaps": false,
"optimizeFonts": true,
"excludeDefaultMomentLocales": true,
"serverRuntimeConfig": {},
"publicRuntimeConfig": {},
"reactProductionProfiling": false,
"reactStrictMode": true,
"httpAgentOptions": {
Expand Down
1 change: 0 additions & 1 deletion docs/01-app/02-guides/environment-variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ This allows you to use a singular Docker image that can be promoted through mult
**Good to know:**

- You can run code on server startup using the [`register` function](/docs/app/guides/instrumentation).
- We do not recommend using the [`runtimeConfig`](/docs/pages/api-reference/config/next-config-js/runtime-configuration) option, as this does not work with the standalone output mode. Instead, we recommend [incrementally adopting](/docs/app/guides/migrating/app-router-migration) the App Router if you need this feature.

## Test Environment Variables

Expand Down
1 change: 0 additions & 1 deletion docs/01-app/02-guides/self-hosting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ This allows you to use a singular Docker image that can be promoted through mult
> **Good to know:**
>
> - You can run code on server startup using the [`register` function](/docs/app/guides/instrumentation).
> - We do not recommend using the [runtimeConfig](/docs/pages/api-reference/config/next-config-js/runtime-configuration) option, as this does not work with the standalone output mode. Instead, we recommend [incrementally adopting](/docs/app/guides/migrating/app-router-migration) the App Router.
## Caching and ISR

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ node .next/standalone/server.js

> **Good to know**:
>
> - `next.config.js` is read during `next build` and serialized into the `server.js` output file. If the legacy [`serverRuntimeConfig` or `publicRuntimeConfig` options](/docs/pages/api-reference/config/next-config-js/runtime-configuration) are being used, the values will be specific to values at build time.
> - `next.config.js` is read during `next build` and serialized into the `server.js` output file.
> - If your project needs to listen to a specific port or hostname, you can define `PORT` or `HOSTNAME` environment variables before running `server.js`. For example, run `PORT=8080 HOSTNAME=0.0.0.0 node server.js` to start the server on `http://0.0.0.0:8080`.

</PagesOnly>
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions packages/next/config.d.ts

This file was deleted.

12 changes: 0 additions & 12 deletions packages/next/config.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/// <reference path="./dist/styled-jsx/types/index.d.ts" />
/// <reference path="./app.d.ts" />
/// <reference path="./cache.d.ts" />
/// <reference path="./config.d.ts" />
/// <reference path="./document.d.ts" />
/// <reference path="./dynamic.d.ts" />
/// <reference path="./error.d.ts" />
Expand Down
9 changes: 1 addition & 8 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1924,9 +1924,7 @@ export default async function build(
}
}

const { configFileName, publicRuntimeConfig, serverRuntimeConfig } =
config
const runtimeEnvConfig = { publicRuntimeConfig, serverRuntimeConfig }
const { configFileName } = config
const sriEnabled = Boolean(config.experimental.sri?.algorithm)

const nonStaticErrorPageSpan = staticCheckSpan.traceChild(
Expand All @@ -1939,7 +1937,6 @@ export default async function build(
(await worker.hasCustomGetInitialProps({
page: '/_error',
distDir,
runtimeEnvConfig,
checkingApp: false,
sriEnabled,
}))
Expand All @@ -1953,7 +1950,6 @@ export default async function build(
page: '/_error',
distDir,
configFileName,
runtimeEnvConfig,
cacheComponents: isAppCacheComponentsEnabled,
authInterrupts: isAuthInterruptsEnabled,
httpAgentOptions: config.httpAgentOptions,
Expand All @@ -1973,7 +1969,6 @@ export default async function build(
? worker.hasCustomGetInitialProps({
page: appPageToCheck,
distDir,
runtimeEnvConfig,
checkingApp: true,
sriEnabled,
})
Expand All @@ -1983,7 +1978,6 @@ export default async function build(
? worker.getDefinedNamedExports({
page: appPageToCheck,
distDir,
runtimeEnvConfig,
sriEnabled,
})
: Promise.resolve([])
Expand Down Expand Up @@ -2167,7 +2161,6 @@ export default async function build(
originalAppPath,
distDir,
configFileName,
runtimeEnvConfig,
httpAgentOptions: config.httpAgentOptions,
locales: config.i18n?.locales,
defaultLocale: config.i18n?.defaultLocale,
Expand Down
6 changes: 0 additions & 6 deletions packages/next/src/build/templates/edge-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,6 @@ async function requestHandler(
distDir: '',
crossOrigin: nextConfig.crossOrigin ? nextConfig.crossOrigin : undefined,
largePageDataBytes: nextConfig.experimental.largePageDataBytes,
// Only the `publicRuntimeConfig` key is exposed to the client side
// It'll be rendered as part of __NEXT_DATA__ on the client side
runtimeConfig:
Object.keys(nextConfig.publicRuntimeConfig).length > 0
? nextConfig.publicRuntimeConfig
: undefined,

isExperimentalCompile: nextConfig.experimental.isExperimentalCompile,
// `htmlLimitedBots` is passed to server as serialized config in string format
Expand Down
16 changes: 0 additions & 16 deletions packages/next/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@ export async function isPageStatic({
page,
distDir,
configFileName,
runtimeEnvConfig,
httpAgentOptions,
locales,
defaultLocale,
Expand All @@ -653,7 +652,6 @@ export async function isPageStatic({
cacheComponents: boolean
authInterrupts: boolean
configFileName: string
runtimeEnvConfig: any
httpAgentOptions: NextConfigComplete['httpAgentOptions']
locales?: readonly string[]
defaultLocale?: string
Expand Down Expand Up @@ -701,9 +699,6 @@ export async function isPageStatic({
const isPageStaticSpan = trace('is-page-static-utils', parentId)
return isPageStaticSpan
.traceAsyncFn(async (): Promise<PageIsStaticResult> => {
;(
require('../shared/lib/runtime-config.external') as typeof import('../shared/lib/runtime-config.external')
).setConfig(runtimeEnvConfig)
setHttpClientAndAgentOptions({
httpAgentOptions,
})
Expand Down Expand Up @@ -1003,20 +998,14 @@ export function reduceAppConfig(
export async function hasCustomGetInitialProps({
page,
distDir,
runtimeEnvConfig,
checkingApp,
sriEnabled,
}: {
page: string
distDir: string
runtimeEnvConfig: any
checkingApp: boolean
sriEnabled: boolean
}): Promise<boolean> {
;(
require('../shared/lib/runtime-config.external') as typeof import('../shared/lib/runtime-config.external')
).setConfig(runtimeEnvConfig)

const { ComponentMod } = await loadComponents({
distDir,
page: page,
Expand All @@ -1039,17 +1028,12 @@ export async function hasCustomGetInitialProps({
export async function getDefinedNamedExports({
page,
distDir,
runtimeEnvConfig,
sriEnabled,
}: {
page: string
distDir: string
runtimeEnvConfig: any
sriEnabled: boolean
}): Promise<ReadonlyArray<string>> {
;(
require('../shared/lib/runtime-config.external') as typeof import('../shared/lib/runtime-config.external')
).setConfig(runtimeEnvConfig)
const { ComponentMod } = await loadComponents({
distDir,
page: page,
Expand Down
7 changes: 0 additions & 7 deletions packages/next/src/client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
urlQueryToSearchParams,
assign,
} from '../shared/lib/router/utils/querystring'
import { setConfig } from '../shared/lib/runtime-config.external'
import { getURL, loadGetInitialProps, ST } from '../shared/lib/utils'
import type { NextWebVitalsMetric, NEXT_DATA } from '../shared/lib/utils'
import { Portal } from './portal'
Expand Down Expand Up @@ -212,12 +211,6 @@ export async function initialize(opts: { devClient?: any } = {}): Promise<{
// So, this is how we do it in the client side at runtime
;(self as any).__next_set_public_path__(`${prefix}/_next/`) //eslint-disable-line

// Initialize next/config with the environment configuration
setConfig({
serverRuntimeConfig: {},
publicRuntimeConfig: initialData.runtimeConfig || {},
})

asPath = getURL()

// make sure not to attempt stripping basePath for 404s
Expand Down
6 changes: 0 additions & 6 deletions packages/next/src/export/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,6 @@ async function exportAppImpl(
nextConfig.experimental.enablePrerenderSourceMaps === true,
}

const { publicRuntimeConfig } = nextConfig

if (Object.keys(publicRuntimeConfig).length > 0) {
renderOpts.runtimeConfig = publicRuntimeConfig
}

// We need this for server rendering the Link component.
;(globalThis as any).__NEXT_DATA__ = {
nextExport: true,
Expand Down
1 change: 0 additions & 1 deletion packages/next/src/export/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export interface ExportPageInput {
renderOpts: WorkerRenderOptsPartial
trailingSlash?: boolean
buildExport?: boolean
serverRuntimeConfig: { [key: string]: any }
subFolders?: boolean
optimizeCss: any
disableOptimizedLoading: any
Expand Down
11 changes: 0 additions & 11 deletions packages/next/src/export/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ import type { PagesRenderContext, PagesSharedContext } from '../server/render'
import type { AppSharedContext } from '../server/app-render/app-render'
import { MultiFileWriter } from '../lib/multi-file-writer'
import { createRenderResumeDataCache } from '../server/resume-data-cache/resume-data-cache'

const envConfig =
require('../shared/lib/runtime-config.external') as typeof import('../shared/lib/runtime-config.external')

;(globalThis as any).__NEXT_DATA__ = {
nextExport: true,
}
Expand All @@ -75,7 +71,6 @@ async function exportPageImpl(
distDir,
pagesDataDir,
buildExport = false,
serverRuntimeConfig,
subFolders = false,
optimizeCss,
disableOptimizedLoading,
Expand Down Expand Up @@ -189,11 +184,6 @@ async function exportPageImpl(
addRequestMeta(req, 'isLocaleDomain', true)
}

envConfig.setConfig({
serverRuntimeConfig,
publicRuntimeConfig: commonRenderOpts.runtimeConfig,
})

const getHtmlFilename = (p: string) =>
subFolders ? `${p}${sep}index.html` : `${p}.html`

Expand Down Expand Up @@ -402,7 +392,6 @@ export async function exportPages(
pagesDataDir,
renderOpts,
trailingSlash: nextConfig.trailingSlash,
serverRuntimeConfig: nextConfig.serverRuntimeConfig,
subFolders: nextConfig.trailingSlash && !options.buildExport,
buildExport: options.buildExport,
optimizeCss: nextConfig.experimental.optimizeCss,
Expand Down
22 changes: 1 addition & 21 deletions packages/next/src/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import {
UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,
} from '../shared/lib/constants'
import { isDynamicRoute } from '../shared/lib/router/utils'
import { setConfig } from '../shared/lib/runtime-config.external'
import { execOnce } from '../shared/lib/utils'
import { isBlockedPage } from './utils'
import { getBotType, isBot } from '../shared/lib/router/utils/is-bot'
Expand Down Expand Up @@ -476,14 +475,7 @@ export default abstract class Server<
? new LocaleRouteNormalizer(this.i18nProvider)
: undefined

// Only serverRuntimeConfig needs the default
// publicRuntimeConfig gets it's default in client/index.js
const {
serverRuntimeConfig = {},
publicRuntimeConfig,
assetPrefix,
generateEtags,
} = this.nextConfig
const { assetPrefix, generateEtags } = this.nextConfig

this.buildId = this.getBuildId()
// this is a hack to avoid Webpack knowing this is equal to this.minimalMode
Expand Down Expand Up @@ -550,12 +542,6 @@ export default abstract class Server<
? this.nextConfig.crossOrigin
: undefined,
largePageDataBytes: this.nextConfig.experimental.largePageDataBytes,
// Only the `publicRuntimeConfig` key is exposed to the client side
// It'll be rendered as part of __NEXT_DATA__ on the client side
runtimeConfig:
Object.keys(publicRuntimeConfig).length > 0
? publicRuntimeConfig
: undefined,

isExperimentalCompile: this.nextConfig.experimental.isExperimentalCompile,
// `htmlLimitedBots` is passed to server as serialized config in string format
Expand All @@ -582,12 +568,6 @@ export default abstract class Server<
reactMaxHeadersLength: this.nextConfig.reactMaxHeadersLength,
}

// Initialize next/config with the environment configuration
setConfig({
serverRuntimeConfig,
publicRuntimeConfig,
})

this.pagesManifest = this.getPagesManifest()
this.appPathsManifest = this.getAppPathsManifest()
this.appPathRoutes = this.getAppPathRoutes()
Expand Down
2 changes: 0 additions & 2 deletions packages/next/src/server/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,6 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
pageExtensions: z.array(z.string()).min(1).optional(),
poweredByHeader: z.boolean().optional(),
productionBrowserSourceMaps: z.boolean().optional(),
publicRuntimeConfig: z.record(z.string(), z.any()).optional(),
reactCompiler: z.union([
z.boolean(),
z
Expand Down Expand Up @@ -675,7 +674,6 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
.catchall(z.any())
.optional(),
serverExternalPackages: z.array(z.string()).optional(),
serverRuntimeConfig: z.record(z.string(), z.any()).optional(),
skipMiddlewareUrlNormalize: z.boolean().optional(),
skipTrailingSlashRedirect: z.boolean().optional(),
staticPageGenerationTimeout: z.number().optional(),
Expand Down
Loading
Loading