From 1d6ef2e1b3140231abf7d422e8799c8e873d95b8 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 31 Oct 2023 22:32:29 -0400 Subject: [PATCH] perf: Remove unneeded query before custom domain redirect --- server/routes/index.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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, });