Master zero-cost wildcard subdomain architecture, standalone HTML5 payloads, SEO engineering, and Firebase Spark optimization.
Understand how DNS wildcard records (*.myfa.page) and Next.js Edge Middleware route unlimited tenant subdomains on a $0 serverless budget.
export function middleware(request) {
const host = (request.headers.get("host") || "").split(":")[0];
if (host.endsWith(".myfa.page")) {
const sub = host.replace(".myfa.page", "");
const url = request.nextUrl.clone();
url.pathname = `/sites/${sub}${url.pathname === "/" ? "" : url.pathname}`;
return NextResponse.rewrite(url);
}
return NextResponse.next();
}