diff --git a/src/middleware.ts b/src/middleware.ts index f2c05c6..2964296 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -12,11 +12,13 @@ function getSubdomain(req: NextRequest): string | null { const portIndex = host.indexOf(":"); const hostname = portIndex !== -1 ? host.slice(0, portIndex) : host; - if (hostname === apex || hostname === `www.${apex}`) return null; + const reserved = ["www", "coolify", "mail", "accounts", "clerk", "clk", "clk2", "clkmail"]; + + if (hostname === apex || reserved.includes(hostname) || hostname === `www.${apex}`) return null; if (hostname.endsWith(`.${apex}`)) { const sub = hostname.slice(0, hostname.length - apex.length - 1); - if (sub && sub !== "www") return sub; + if (sub && !reserved.includes(sub)) return sub; } return null;