Drop‑in middleware that resolves tenants securely and reliably in production.
Stop spending hours debugging tenant resolution logic. Start shipping a system that works on the first deploy.
You try to handle subdomains, custom domains, proxies, and edge runtimes, but everything breaks the moment real traffic hits. You patch one DNS issue and another appears. You fix header spoofing and suddenly a reverse proxy strips something you relied on. You’re not writing product features — you’re fighting the request pipeline.
This pack gives you production‑grade Next.js tenant resolution as drop‑in middleware: fully tested, fully commented, and hardened against the edge cases that free GitHub repos don’t cover. Instead of writing and debugging your own resolver for 6 hours, you install this pack and finish in under 20 minutes.
What's Included:
- Core tenant‑resolution middleware that normalizes hostnames and validates domain mappings
- Domain‑parsing module with safe fallbacks for malformed requests and IPv6/IPv4 quirks
- Secure header‑validation layer preventing tenant spoofing through forwarded headers
- Registry module with in‑memory and optional external cache to eliminate 200–500 ms cold lookups
- Cloudflare and Vercel edge‑runtime variants handling their proxy and header differences
- Reverse‑proxy and load‑balancer configuration examples for real production networks
- DNS mapping utilities covering subdomains, wildcard domains, and custom domain ownership checks
- Full test suite covering resolution logic across 40+ edge‑case scenarios
- Fully commented code so you understand every decision and can extend safely
Built from patterns proven in multi‑tenant SaaS apps running across Vercel, Cloudflare, and containerized deployments behind reverse proxies. This is the middleware I wish existed after reviewing broken tenant‑resolution setups for dozens of teams and seeing the same failures repeat.
Who This Is For:
- SaaS developers shipping multi‑tenant apps who need reliable host‑based routing
- Teams migrating to Next.js middleware or edge runtimes and unsure how proxies affect resolution
- Developers tired of mysterious DNS or header issues appearing only in production
Who This Is NOT For:
- Apps that don’t use hostnames, subdomains, or custom domains
- Developers who want to write their own resolver from scratch for learning purposes
If this doesn’t save you at least several hours of implementation and debugging time, reach out for a full refund.