diff --git a/server/routes/index.ts b/server/routes/index.ts index ecd0abee8..8c3b072ff 100644 --- a/server/routes/index.ts +++ b/server/routes/index.ts @@ -130,6 +130,13 @@ router.get("/s/:shareId/*", renderShare); // catch all for application router.get("*", async (ctx, next) => { const team = await getTeamFromContext(ctx); + + // Redirect all requests to custom domain if one is set + if (team?.domain && team.domain !== ctx.hostname) { + ctx.redirect(ctx.href.replace(ctx.hostname, team.domain)); + return; + } + const analytics = team ? await Integration.findOne({ where: { @@ -139,12 +146,6 @@ router.get("*", async (ctx, next) => { }) : undefined; - // Redirect all requests to custom domain if one is set - if (team?.domain && team.domain !== ctx.hostname) { - ctx.redirect(ctx.href.replace(ctx.hostname, team.domain)); - return; - } - return renderApp(ctx, next, { analytics, });