From 74ce4052c490f220d2425b9419081cad06baf804 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 24 Jan 2026 09:59:20 -0500 Subject: [PATCH] fix: Unused subdomains should redirect to root (#11259) * fix: Unused subdomains should redirect to root * test --- server/routes/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/routes/index.ts b/server/routes/index.ts index 54f7828323..41f74b2f0f 100644 --- a/server/routes/index.ts +++ b/server/routes/index.ts @@ -155,8 +155,16 @@ router.get("*", async (ctx, next) => { const team = await getTeamFromContext(ctx); if (env.isCloudHosted) { + // Redirect to main domain if no team is found + if (!team || team.isSuspended) { + if (env.isProduction && ctx.hostname !== parseDomain(env.URL).host) { + ctx.redirect(env.URL); + return; + } + } + // Redirect all requests to custom domain if one is set - if (team?.domain) { + else if (team?.domain) { if (team.domain !== ctx.hostname) { ctx.redirect(ctx.href.replace(ctx.hostname, team.domain)); return;