GoLink

Subdomain Architecture

How GoLink uses Next.js middleware and reverse proxy for unified multi-tenant routing.


Subdomain Architecture & Edge Routing

GoLink runs on a unified Next.js codebase that powers multiple subdomains from a single deployment. By pairing Next.js App Router folders with custom reverse proxy middleware, every request is dynamically resolved to its dedicated sub-application.


The Hostname Routing Table

When a request arrives at GoLink, the proxy middleware inspects the incoming Host header and URL path:

SubdomainEnvironment MapRoute HandledHandler
golink.buzzlocalhost:3000Landing Page & /docsapp/(root) & app/docs
app.golink.buzzapp.localhost:3000Dashboard & Consoleapp/app.golink.buzz
auth.golink.buzzauth.localhost:3000Sign In, Register, Authapp/auth.golink.buzz
admin.golink.buzzadmin.localhost:3000Platform Admin Consoleapp/admin.golink.buzz
go.golink.buzzgo.localhost:3000Short Link Redirectionapp/go.golink.buzz
*.custom-domain.comAny custom CNAMEBranded Short Linksapp/go.golink.buzz

Directory Tree

Here is how the project routes are organized in the Next.js App Router:

app
(root)
page.tsx
admin.golink.buzz
domains
links
users
page.tsx
app.golink.buzz
[orgSlug]
analytics
domains
links
settings
page.tsx
auth.golink.buzz
auth
login
register
docs
[[...slug]]
page.tsx
layout.tsx
go.golink.buzz
[shortLink]
page.tsx
api
links
domains
analytics
proxy.ts
middleware.ts

How proxy.ts Works

The edge middleware parses the incoming request domain and selectively redirects or rewrites the request internally:

proxy.ts
export async function proxy(req: NextRequest) { const { domain, path, search } = parseReq(req); // 1. Dashboard app (app.golink.buzz) if (DASH_HOSTNAMES.has(domain)) { return AppMiddleware(req); } // 2. Auth portal (auth.golink.buzz) if (AUTH_HOSTNAMES.has(domain)) { if (path === "/") { return NextResponse.redirect(new URL(`/auth/login${search}`, req.url)); } return NextResponse.rewrite(new URL(`/auth.golink.buzz${path}${search}`, req.url)); } // 3. Admin portal (admin.golink.buzz) if (ADMIN_HOSTNAMES.has(domain)) { return AdminMiddleware(req); } // 4. Marketing website & Docs (golink.buzz) if (MAIN_HOSTNAMES.has(domain)) { return NextResponse.next(); } // 5. Short link redirection (go.golink.buzz & custom domains) return NextResponse.rewrite(new URL(`/go.golink.buzz${path}${search}`, req.url)); }

Because short link redirection uses Next.js NextResponse.rewrite(), the client's address bar retains the custom branded domain (e.g., go.yourcompany.com/launch) while internally rendering the optimized redirector route.

Last updated on October 20, 2026