diff --git a/app/[domain]/[slug]/page.tsx b/app/[domain]/[slug]/page.tsx index fb1f928..da65d3d 100644 --- a/app/[domain]/[slug]/page.tsx +++ b/app/[domain]/[slug]/page.tsx @@ -57,6 +57,12 @@ export async function generateStaticParams() { }, }, }, + // feel free to remove this filter if you want to generate paths for all posts + where: { + site: { + subdomain: "demo", + }, + }, }); const allPaths = allPosts diff --git a/app/[domain]/page.tsx b/app/[domain]/page.tsx index 49d78ee..6596d96 100644 --- a/app/[domain]/page.tsx +++ b/app/[domain]/page.tsx @@ -13,6 +13,10 @@ export async function generateStaticParams() { subdomain: true, customDomain: true, }, + // feel free to remove this filter if you want to generate paths for all sites + where: { + subdomain: "demo", + }, }); const allPaths = allSites diff --git a/lib/actions.ts b/lib/actions.ts index f7e937c..ffe5fdc 100644 --- a/lib/actions.ts +++ b/lib/actions.ts @@ -85,7 +85,11 @@ export const updateSite = withSiteAuth( customDomain: value, }, }); - await addDomainToVercel(value); + await Promise.all([ + addDomainToVercel(value), + // Optional: add www subdomain as well and redirect to apex domain + // addDomainToVercel(`www.${value}`), + ]); // empty value means the user wants to remove the custom domain } else if (value === "") { diff --git a/middleware.ts b/middleware.ts index 3b78195..cd1c1d6 100644 --- a/middleware.ts +++ b/middleware.ts @@ -18,12 +18,10 @@ export default async function middleware(req: NextRequest) { const url = req.nextUrl; // Get hostname of request (e.g. demo.vercel.pub, demo.localhost:3000) - let hostname = req.headers + const hostname = req.headers .get("host")! .replace(".localhost:3000", `.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`); - hostname = hostname.replace("www.", ""); // remove www. from domain - const searchParams = req.nextUrl.searchParams.toString(); // Get the pathname of the request (e.g. /, /about, /blog/first-post) const path = `${url.pathname}${