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;