Cartitarul
Verified User
- Joined
- Jul 19, 2023
- Messages
- 38
Hello,
I’m trying to run a Next.js application (App Router) on a server using DirectAdmin + Nginx Unit, and I’m running into what looks like a compatibility issue.
When running the app via Unit, it crashes during SSR with:
From debugging, it appears that Next.js expects a standard Node http.ServerResponse, but Unit’s Node HTTP adapter provides a response object that doesn’t fully match Node’s API, causing Next SSR to fail.
Is modern Next.js (App Router + SSR + API routes) officially supported on Nginx Unit?
If not:
Thanks in advance for any clarification.
I’m trying to run a Next.js application (App Router) on a server using DirectAdmin + Nginx Unit, and I’m running into what looks like a compatibility issue.
My setup
- DirectAdmin with Nginx Unit
- Node.js (tested Node 24, also tried downgrading)
- Next.js (App Router, using /app)
- The app includes API routes (e.g. /app/api/projects, /app/api/admin/session)
- Previously worked locally using npm run dev and npm run start
What I tried
- Created a Unit Node application with a proper server.js
- Installed dependencies and ran npm run build
- Confirmed .next/ build output exists
- Ensured Unit working directory is correct
- Cleaned up workspace/lockfile issues
- Tried static export (output: "export") but it fails due to API routes (expected)
The error
When running the app via Unit, it crashes during SSR with:
This happens consistently inside .next/server/chunks/ssr/....TypeError: b.appendHeader is not a function
From debugging, it appears that Next.js expects a standard Node http.ServerResponse, but Unit’s Node HTTP adapter provides a response object that doesn’t fully match Node’s API, causing Next SSR to fail.
My question
Is modern Next.js (App Router + SSR + API routes) officially supported on Nginx Unit?
If not:
- Is there a recommended workaround?
- Or is the expected approach to run Next.js outside Unit (Node + pm2) and reverse-proxy with nginx?
Thanks in advance for any clarification.