Skip to content
neatploy.
ENGINEERING · 4 min read

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.

Neatploy Engineering — Runtime & Edge Team
#nextjs #railpack #security #caching

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:

  • PORT set to the allocated service port
  • HOSTNAME=0.0.0.0 so standalone server.js binds outside the container loopback
  • NEXT_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.

GET STARTED

Plan less infrastructure.
Ship more software.

Start with $5 in monthly free credit on your first verified organisation. Connect a GitHub repo or add a database in minutes.

Runtime gVisor (runsc)
Free credit $5.00 / month
Managed backups Every 6h → R2
Traffic swap Zero-downtime