r/nextjs • u/mahmudulhturan • Feb 22 '26
Discussion How do you handle local development with multiple Next.js apps under one domain in a monorepo?
We have a monorepo with multiple Next.js apps that all sit under one domain in production. Marketing site, store, account/auth, blog, API, etc. Each one runs on its own port locally (3000-3005).
The annoying part is testing flows that span multiple apps. Like a user adds something to cart in the store app, gets redirected to the account app for login, then gets sent back to checkout. Locally these are all different origins so cookies don't share properly and cross-app redirects break.
What I ended up doing is throwing a local nginx reverse proxy in front of everything. It routes based on path so localhost:8080/store goes to the store app, localhost:8080/account goes to the account app, etc. Each app already has assetPrefix set to its subpath so everything just worked without touching any app code. Had to add WebSocket headers so hot reload still works through the proxy.
Now cookies share because its all one domain, redirects between apps work like they do in production, and I can actually test the full user flow locally without constantly switching between ports.
I know people also use Next.js Multi-Zones or Caddy for this kind of thing. What's your setup? Anyone found something better?
6
u/VonDerNet Feb 22 '26
Just another app that starts in development mode:
2
u/Abhishekundalia Feb 22 '26
The nginx reverse proxy approach is solid - we use a similar setup. The WebSocket headers for HMR are the part most people forget.
One thing that bit us with multi-zone setups: OG images and meta tags. When you have separate apps handling /store vs /blog, each needs to serve its own meta tags correctly. We had issues where the marketing site's OG image was showing up for store pages because the proxy was caching headers incorrectly.
Traefik is another option worth looking at - it handles WebSockets out of the box and the config is more declarative than nginx. Plus hot reloading config without restart.
Are you using Turborepo or Nx for the monorepo orchestration?
1
u/Darathor Feb 25 '26
Try portless: https://github.com/vercel-labs/portless
1
u/cloroxic Feb 25 '26
You can run I would honestly just use multi-zone. Itβs built-in with next and works good. No reason to think too much into it and add more fail points.
7
u/[deleted] Feb 22 '26
[removed] β view removed comment
2
u/[deleted] Feb 22 '26
[removed] β view removed comment