vercel/next.js · error
Middleware is not supported in minimal mode. Please remove t
Error message
Middleware is not supported in minimal mode. Please remove the `NEXT_MINIMAL` environment variable.
What it means
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.
Source
Thrown at packages/next/src/server/next-server.ts:2027
'clonableBody',
getCloneableBody(req.originalRequest, bodySizeLimit)
)
}
}
protected async runEdgeFunction(params: {
req: NodeNextRequest
res: NodeNextResponse
query: ParsedUrlQuery
params: Params | undefined
page: string
appPaths: string[] | null
match?: RouteMatch
onError?: (err: unknown) => void
onWarning?: (warning: Error) => void
}): Promise<FetchEventResult | null> {
if (process.env.NEXT_MINIMAL) {
throw new Error(
'Middleware is not supported in minimal mode. Please remove the `NEXT_MINIMAL` environment variable.'
)
}
let edgeInfo: ReturnType<typeof this.getEdgeFunctionInfo> | undefined
const { query, page, match } = params
if (!match)
await this.ensureEdgeFunction({
page,
appPaths: params.appPaths,
url: params.req.url,
})
edgeInfo = this.getEdgeFunctionInfo({
page,
middleware: false,
})
View on GitHub (pinned to 0ae8c72462)
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.
Example fix
// before NEXT_MINIMAL=1 next start // after next start
Defensive patterns
Strategy: validation
Validate before calling
if (process.env.NEXT_MINIMAL && hasMiddleware) {
console.warn('NEXT_MINIMAL is set but middleware exists; unsetting NEXT_MINIMAL.')
delete process.env.NEXT_MINIMAL
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- To use middleware you must provide a `hostname` and `port` t
- Config options `experimental.proxyClientMaxBodySize` and `ex
- Config options `experimental.proxyPrefetch` and `experimenta
- Config options `experimental.externalProxyRewritesResolve` a
- Config options `skipProxyUrlNormalize` and `skipMiddlewareUr
AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06).
Data as JSON: /api/errors/001d8147ba1d7014.
Report an issue: GitHub.