Next.js without configuration: caching, skew, and CVE stripping
Why running Next.js as a long-lived container solves serverless timeouts—and how Neatploy handles .next/cache, compression, and middleware header security.
Next.js works cleanly when it runs the way next start was designed to run: as a normal long-lived Node server with no artificial execution timeouts, working WebSockets, and predictable memory behaviour.
Our goal on Neatploy is that a Next.js repository deploys fast and securely with zero platform-specific boilerplate.
Per-service .next/cache persistence
When a repository has no Dockerfile, Railpack automatically detects your package manager (npm, pnpm, Yarn, or Bun), installs dependencies, and preserves .next/cache between builds.
Initially, build caches were shared across services on a build node; we now key .next/cache strictly per service and environment, preventing cross-service cache interference while keeping rebuilds fast.
Runtime defaults without boilerplate
Whenever a build detects Next.js, Neatploy automatically configures three runtime variables unless you override them:
PORTset to the allocated service portHOSTNAME=0.0.0.0so standaloneserver.jsbinds outside the container loopbackNEXT_TELEMETRY_DISABLED=1
Edge security and multi-replica caching
At the Caddy edge, every Next.js service gets gzip/zstd compression and automatic stripping of internal headers like x-middleware-subrequest before requests reach your app—protecting against middleware authorization bypasses such as CVE-2025-29927. During builds, our builder also checks your installed next version against osv.dev advisories and logs a warning if an upgrade is recommended.
When scaling beyond one replica, remember that each container keeps its own disk cache; pair your app with a managed Redis 7 service in the same environment and prefix cache keys with NEATPLOY_DEPLOYMENT_ID. See our Next.js guide for setup details.