{"record":{"id":"0ddd20a432471d92","repo":"vercel/next.js","slug":"you-can-not-have-a-next-folder-inside-of-your-p","errorCode":null,"errorMessage":"You can not have a '_next' folder inside of your public folder. This conflicts with the internal '/_next' route. https://nextjs.org/docs/messages/public-next-folder-conflict","messagePattern":"You can not have a '_next' folder inside of your public folder\\. This conflicts with the internal '/_next' route\\. https://nextjs\\.org/docs/messages/public-next-folder-conflict","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/dev/next-dev-server.ts","lineNumber":652,"sourceCode":"  ): Promise<void> {\n    await this.ready?.promise\n\n    const { basePath } = this.nextConfig\n    let originalPathname: string | null = null\n\n    // TODO: see if we can remove this in the future\n    if (basePath && pathHasPrefix(parsedUrl.pathname || '/', basePath)) {\n      // strip basePath before handling dev bundles\n      // If replace ends up replacing the full url it'll be `undefined`, meaning we have to default it to `/`\n      originalPathname = parsedUrl.pathname\n      parsedUrl.pathname = removePathPrefix(parsedUrl.pathname || '/', basePath)\n    }\n\n    const { pathname } = parsedUrl\n\n    if (pathname!.startsWith('/_next')) {\n      if (fs.existsSync(pathJoin(this.publicDir, '_next'))) {\n        throw new Error(PUBLIC_DIR_MIDDLEWARE_CONFLICT)\n      }\n    }\n\n    if (originalPathname) {\n      // restore the path before continuing so that custom-routes can accurately determine\n      // if they should match against the basePath or not\n      parsedUrl.pathname = originalPathname\n    }\n    try {\n      return await super.run(req, res, parsedUrl)\n    } catch (error) {\n      const err = getProperError(error)\n      formatServerError(err)\n      this.logErrorWithOriginalStack(err)\n      if (!res.sent) {\n        res.statusCode = 500\n        try {\n          return await this.renderError(err, req, res, pathname!, {","sourceCodeStart":634,"sourceCodeEnd":670,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/dev/next-dev-server.ts#L634-L670","documentation":"Thrown by the dev server's run() when an incoming request path starts with /_next and a directory literally named _next exists inside the project's public folder. Next.js reserves /_next as the internal asset route; a public/_next folder collides with it and would shadow or be shadowed by framework assets. The check uses fs.existsSync(pathJoin(publicDir, '_next')) and throws PUBLIC_DIR_MIDDLEWARE_CONFLICT.","triggerScenarios":"A request to any /_next/* path (asset, chunk, etc.) is handled while public/_next exists on disk. The dev server detects the conflict and throws immediately, blocking the request.","commonSituations":"A user or scaffolding tool created public/_next (e.g. copying build output, a CMS export, or misreading docs). Renaming a folder to _next for organization. A static-export import that wrote into public. A previous `next export` whose output was copied into public.","solutions":["Delete or rename the public/_next directory: `rm -rf public/_next`.","Move its contents elsewhere (e.g. public/assets/) and update any references.","Search the codebase/config for anything that generates public/_next and stop it.","Restart the dev server after removing the directory."],"exampleFix":"# before\npublic/\n  _next/\n    static/\n\n# after\nrm -rf public/_next\n# use a non-reserved folder name if you need static assets\npublic/assets/","handlingStrategy":"validation","validationCode":"import fs from 'fs'\nimport path from 'path'\n// Fail fast in a prebuild script if the reserved folder exists\nfunction assertNoPublicNext(publicDir: string) {\n  if (fs.existsSync(path.join(publicDir, '_next'))) {\n    throw new Error('public/_next conflicts with /_next route; remove it.')\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never name a public asset folder _next.","Add a CI check that public/_next does not exist.","Review static-export/CMS outputs before copying into public."],"tags":["filesystem","dev-server","config","public-dir"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}