Why my single Next.js app runs 4 different domains (and how the proxy.ts decides who sees what)
The article discusses how a single Next.js application can effectively manage four different domains. It highlights the use of a proxy.ts file to route requests based on the host, allowing for distinct functionalities across each domain. The author shares insights on the challenges faced and the advantages of this multi-domain approach for a SaaS product.
- ▪The author runs four different domains from one Next.js codebase, including a marketing site and an authenticated app.
- ▪A single proxy.ts file is used to manage routing and request handling for the different domains.
- ▪This multi-domain strategy helps isolate reputation and functionality, preventing issues like spam affecting the main brand.
Opening excerpt (first ~120 words) tap to expand
try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 3936949) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } Youssefroop Posted on May 30 Why my single Next.js app runs 4 different domains (and how the proxy.ts decides who sees what) #nextjs #architecture #saas #buildinpublic > TL;DR — I run four different domains off one Next.js codebase: a marketing site at pagestrike.com, an authenticated app at app.pagestrike.com, a public publishing domain at pagestrike.app, and customer-owned domains.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV.to (Top).