{"record":{"id":"af632575993fcef0","repo":"vercel/next.js","slug":"the-key-key-under-env-in-config-configfil","errorCode":null,"errorMessage":"The key \"${key}\" under \"env\" in ${config.configFileName || 'config'} is not allowed. https://nextjs.org/docs/messages/env-key-not-allowed","messagePattern":"The key \"(.+?)\" under \"env\" in (.+?) is not allowed\\. https://nextjs\\.org/docs/messages/env-key-not-allowed","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/lib/static-env.ts","lineNumber":14,"sourceCode":"import type {\n  NextConfigComplete,\n  NextConfigRuntime,\n} from '../server/config-shared'\n\nfunction errorIfEnvConflicted(\n  config: NextConfigComplete | NextConfigRuntime,\n  key: string\n) {\n  const isPrivateKey = /^(?:NODE_.+)|^(?:__.+)$/i.test(key)\n  const hasNextRuntimeKey = key === 'NEXT_RUNTIME'\n\n  if (isPrivateKey || hasNextRuntimeKey) {\n    throw new Error(\n      `The key \"${key}\" under \"env\" in ${config.configFileName || 'config'} is not allowed. https://nextjs.org/docs/messages/env-key-not-allowed`\n    )\n  }\n}\n\n/**\n * Collects all environment variables that are using the `NEXT_PUBLIC_` prefix.\n */\nexport function getNextPublicEnvironmentVariables() {\n  const defineEnv: [string, string | undefined][] = []\n  for (const key in process.env) {\n    if (key.startsWith('NEXT_PUBLIC_')) {\n      const value = process.env[key]\n      if (value != null) {\n        defineEnv.push([`process.env.${key}`, value])\n      }\n    }\n  }","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/lib/static-env.ts#L1-L32","documentation":"Env-name validation in errorIfEnvConflicted: a key under next.config's env map matched the reserved patterns NODE_*, __*, or was exactly NEXT_RUNTIME. Those names are controlled by Next.js/Node itself, so injecting them via config would silently override runtime behavior and is rejected.","triggerScenarios":"A disallowed key is defined under env in next.config.","commonSituations":"Defining a reserved or NODE_ENV-like key in the env config block.","solutions":["Remove the disallowed key from the env config; keys starting with NODE_ or reserved names cannot be used."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eb377541648e63402a47b38fee00a8d0ce8f8f1","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}