diff --git a/packages/nextjs/src/index.server.ts b/packages/nextjs/src/index.server.ts index d060c02e61bb..e5d43a44fd8c 100644 --- a/packages/nextjs/src/index.server.ts +++ b/packages/nextjs/src/index.server.ts @@ -93,8 +93,9 @@ function sdkAlreadyInitialized(): boolean { } function addServerIntegrations(options: NextjsOptions): void { - // This value is injected at build time, based on the output directory specified in the build config - const distDirName = (global as GlobalWithDistDir).__rewriteFramesDistDir__; + // This value is injected at build time, based on the output directory specified in the build config. Though a default + // is set there, we set it here as well, just in case something has gone wrong with the injection. + const distDirName = (global as GlobalWithDistDir).__rewriteFramesDistDir__ || '.next'; // nextjs always puts the build directory at the project root level, which is also where you run `next start` from, so // we can read in the project directory from the currently running process const distDirAbsPath = path.resolve(process.cwd(), distDirName);