MCPcopy
hub / github.com/vercel/next.js / constructor

Function constructor

packages/next/src/server/base-server.ts:442–612  ·  view source on GitHub ↗

* This is used to persist cache scopes across * prefetch -> full route requests for cache components * it's only fully used in dev

(options: ServerOptions)

Source from the content-addressed store, hash-verified

440 */
441
442 public constructor(options: ServerOptions) {
443 const {
444 dir = '.',
445 quiet = false,
446 conf,
447 dev = false,
448 minimalMode = false,
449 hostname,
450 port,
451 experimentalTestProxy,
452 } = options
453
454 this.dev = dev
455 this.experimentalTestProxy = experimentalTestProxy
456 this.serverOptions = options
457
458 this.dir = path.resolve(/* turbopackIgnore: true */ dir)
459
460 this.quiet = quiet
461 this.loadEnvConfig({ dev, forceReload: false })
462
463 // TODO: should conf be normalized to prevent missing
464 // values from causing issues as this can be user provided
465 this.nextConfig = conf as NextConfigRuntime
466
467 if (this.nextConfig.experimental.runtimeServerDeploymentId) {
468 if (!process.env.NEXT_DEPLOYMENT_ID) {
469 throw new Error(
470 'process.env.NEXT_DEPLOYMENT_ID is missing but runtimeServerDeploymentId is enabled'
471 )
472 }
473 this.deploymentId = process.env.NEXT_DEPLOYMENT_ID
474 } else {
475 let id = this.nextConfig.experimental.useSkewCookie
476 ? ''
477 : this.nextConfig.deploymentId || ''
478
479 this.deploymentId = id
480 process.env.NEXT_DEPLOYMENT_ID = id
481 }
482 ;(globalThis as any).NEXT_CLIENT_ASSET_SUFFIX =
483 this.nextConfig.experimental.immutableAssetToken || this.deploymentId
484 ? `?dpl=${this.nextConfig.experimental.immutableAssetToken || this.deploymentId}`
485 : ''
486
487 this.hostname = hostname
488 if (this.hostname) {
489 // we format the hostname so that it can be fetched
490 this.fetchHostname = formatHostname(this.hostname)
491 }
492 this.port = port
493 this.distDir = path.join(
494 /* turbopackIgnore: true */ this.dir,
495 this.nextConfig.distDir
496 )
497 this.publicDir = this.getPublicDir()
498 this.hasStaticDir = !minimalMode && this.getHasStaticDir()
499

Callers

nothing calls this directly

Calls 15

formatHostnameFunction · 0.90
checkIsAppPPREnabledFunction · 0.90
loadEnvConfigMethod · 0.80
getPublicDirMethod · 0.80
getHasStaticDirMethod · 0.80
getEnabledDirectoriesMethod · 0.80
getPrerenderManifestMethod · 0.80
getRouteMatchersMethod · 0.80
resolveMethod · 0.65
reloadMethod · 0.65
setAssetPrefixMethod · 0.65

Tested by

no test coverage detected