{"record":{"id":"ef85356e729ba681","repo":"vercel/next.js","slug":"the-public-directory-is-reserved-in-next-js-and","errorCode":null,"errorMessage":"The 'public' directory is reserved in Next.js and can not be set as the 'distDir'. https://nextjs.org/docs/messages/can-not-output-to-public","messagePattern":"The 'public' directory is reserved in Next\\.js and can not be set as the 'distDir'\\. https://nextjs\\.org/docs/messages/can-not-output-to-public","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/config.ts","lineNumber":389,"sourceCode":"    (currentConfig, key) => {\n      const value = (userConfig as any)[key]\n\n      if (value === undefined || value === null) {\n        return currentConfig\n      }\n\n      if (key === 'distDir') {\n        if (typeof value !== 'string') {\n          throw new Error(\n            `Specified distDir is not a string, found type \"${typeof value}\"`\n          )\n        }\n        const userDistDir = value.trim()\n\n        // don't allow public as the distDir as this is a reserved folder for\n        // public files\n        if (userDistDir === 'public') {\n          throw new Error(\n            `The 'public' directory is reserved in Next.js and can not be set as the 'distDir'. https://nextjs.org/docs/messages/can-not-output-to-public`\n          )\n        }\n        // make sure distDir isn't an empty string as it can result in the provided\n        // directory being deleted in development mode\n        if (userDistDir.length === 0) {\n          throw new Error(\n            `Invalid distDir provided, distDir can not be an empty string. Please remove this config or set it to undefined`\n          )\n        }\n      }\n\n      if (key === 'pageExtensions') {\n        if (!Array.isArray(value)) {\n          throw new Error(\n            `Specified pageExtensions is not an array of strings, found \"${value}\". Please update this config or remove it.`\n          )\n        }","sourceCodeStart":371,"sourceCodeEnd":407,"githubUrl":"https://github.com/vercel/next.js/blob/34433fd12ee8074ea3f47af9f36255c7390d0301/packages/next/src/server/config.ts#L371-L407","documentation":"Config validation in assignDefaultsAndValidate: the distDir string, after trimming, equals 'public'. The public directory is reserved for static assets served from the site root — using it as the build output directory would collide with user files, so the value is rejected outright.","triggerScenarios":"distDir is set to the reserved public directory.","commonSituations":"Configuring distDir: 'public' in next.config, which conflicts with Next.js static serving.","solutions":["Choose a different distDir; 'public' is reserved."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"34433fd12ee8074ea3f47af9f36255c7390d0301","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}