{"record":{"id":"001d8147ba1d7014","repo":"vercel/next.js","slug":"middleware-is-not-supported-in-minimal-mode-pleas","errorCode":null,"errorMessage":"Middleware is not supported in minimal mode. Please remove the `NEXT_MINIMAL` environment variable.","messagePattern":"Middleware is not supported in minimal mode\\. Please remove the `NEXT_MINIMAL` environment variable\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/next-server.ts","lineNumber":2027,"sourceCode":"        'clonableBody',\n        getCloneableBody(req.originalRequest, bodySizeLimit)\n      )\n    }\n  }\n\n  protected async runEdgeFunction(params: {\n    req: NodeNextRequest\n    res: NodeNextResponse\n    query: ParsedUrlQuery\n    params: Params | undefined\n    page: string\n    appPaths: string[] | null\n    match?: RouteMatch\n    onError?: (err: unknown) => void\n    onWarning?: (warning: Error) => void\n  }): Promise<FetchEventResult | null> {\n    if (process.env.NEXT_MINIMAL) {\n      throw new Error(\n        'Middleware is not supported in minimal mode. Please remove the `NEXT_MINIMAL` environment variable.'\n      )\n    }\n    let edgeInfo: ReturnType<typeof this.getEdgeFunctionInfo> | undefined\n\n    const { query, page, match } = params\n\n    if (!match)\n      await this.ensureEdgeFunction({\n        page,\n        appPaths: params.appPaths,\n        url: params.req.url,\n      })\n    edgeInfo = this.getEdgeFunctionInfo({\n      page,\n      middleware: false,\n    })\n","sourceCodeStart":2009,"sourceCodeEnd":2045,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/next-server.ts#L2009-L2045","documentation":"Thrown at the start of NextNodeServer.runEdgeFunction() when process.env.NEXT_MINIMAL is set. Minimal mode is a trimmed runtime (used by certain serverless/edge deployments) that intentionally excludes middleware and edge-function support, so invoking an edge function in that mode is rejected.","triggerScenarios":"The NEXT_MINIMAL environment variable is truthy (set to any value) and a request hits a route handled by middleware or an edge runtime function. runEdgeFunction checks `if (process.env.NEXT_MINIMAL)` and throws before doing any work.","commonSituations":"A serverless/edge platform sets NEXT_MINIMAL by default and the app adds middleware.ts; leftover NEXT_MINIMAL=1 from a previous deployment config copied into a standard Node server; testing a minimal bundle locally while middleware is present.","solutions":["Unset the NEXT_MINIMAL environment variable when you need middleware/edge functions (remove it from your env/Dockerfile/serverless config).","If you intentionally run in minimal mode, remove middleware.ts and any edge runtime route handlers.","Confirm the deployment target actually requires minimal mode; standard `next start` does not."],"exampleFix":"// before\nNEXT_MINIMAL=1 next start\n// after\nnext start","handlingStrategy":"validation","validationCode":"if (process.env.NEXT_MINIMAL && hasMiddleware) {\n  console.warn('NEXT_MINIMAL is set but middleware exists; unsetting NEXT_MINIMAL.')\n  delete process.env.NEXT_MINIMAL\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not set NEXT_MINIMAL unless your deployment target explicitly requires it.","If you run minimal mode, keep middleware.ts and edge routes out of the app.","Document which environments set NEXT_MINIMAL so it isn't carried into standard servers."],"tags":["middleware","edge","environment-variable","minimal-mode"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}