diff --git a/apps/dokploy/pages/index.tsx b/apps/dokploy/pages/index.tsx
index 6bc7a6e2d..3e41abae3 100644
--- a/apps/dokploy/pages/index.tsx
+++ b/apps/dokploy/pages/index.tsx
@@ -5,7 +5,7 @@ import {
} from "@dokploy/server";
import { validateRequest } from "@dokploy/server/lib/auth";
import { standardSchemaResolver as zodResolver } from "@hookform/resolvers/standard-schema";
-import { createServerSideHelpers } from "@trpc/react-query/server";
+import { generateServerSideHelper } from "@/utils/create-server-helpers";
import { REGEXP_ONLY_DIGITS } from "input-otp";
import { Fingerprint } from "lucide-react";
import type { GetServerSidePropsContext } from "next";
@@ -14,7 +14,6 @@ import { useRouter } from "next/router";
import { type ReactElement, useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
-import superjson from "superjson";
import { z } from "zod";
import { OnboardingLayout } from "@/components/layouts/onboarding-layout";
import { SignInWithGithub } from "@/components/proprietary/auth/sign-in-with-github";
@@ -495,17 +494,7 @@ Home.getLayout = (page: ReactElement) => {
return {page};
};
export async function getServerSideProps(context: GetServerSidePropsContext) {
- const helpers = createServerSideHelpers({
- router: appRouter,
- ctx: {
- req: context.req as any,
- res: context.res as any,
- db: null as any,
- session: null as any,
- user: null as any,
- },
- transformer: superjson,
- });
+ const helpers = generateServerSideHelper(appRouter, context);
// Prefetch the public branding so the login/onboarding logo and app name
// render correctly on the server (no flash of default branding).
await helpers.whitelabeling.getPublic.prefetch();
diff --git a/apps/dokploy/pages/invitation.tsx b/apps/dokploy/pages/invitation.tsx
index 153157226..da6482219 100644
--- a/apps/dokploy/pages/invitation.tsx
+++ b/apps/dokploy/pages/invitation.tsx
@@ -1,13 +1,12 @@
import { getUserByToken, IS_CLOUD } from "@dokploy/server";
import { standardSchemaResolver as zodResolver } from "@hookform/resolvers/standard-schema";
-import { createServerSideHelpers } from "@trpc/react-query/server";
+import { generateServerSideHelper } from "@/utils/create-server-helpers";
import type { GetServerSidePropsContext } from "next";
import Link from "next/link";
import { useRouter } from "next/router";
import { type ReactElement, useEffect } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
-import superjson from "superjson";
import { z } from "zod";
import { OnboardingLayout } from "@/components/layouts/onboarding-layout";
import { AlertBlock } from "@/components/shared/alert-block";
@@ -333,17 +332,7 @@ Invitation.getLayout = (page: ReactElement) => {
return {page};
};
export async function getServerSideProps(ctx: GetServerSidePropsContext) {
- const helpers = createServerSideHelpers({
- router: appRouter,
- ctx: {
- req: ctx.req as any,
- res: ctx.res as any,
- db: null as any,
- session: null as any,
- user: null as any,
- },
- transformer: superjson,
- });
+ const helpers = generateServerSideHelper(appRouter, ctx);
// Prefetch the public branding so the invitation logo and app name render
// correctly on the server (no flash of default branding).
await helpers.whitelabeling.getPublic.prefetch();
diff --git a/apps/dokploy/pages/register.tsx b/apps/dokploy/pages/register.tsx
index af1879452..20c95bea6 100644
--- a/apps/dokploy/pages/register.tsx
+++ b/apps/dokploy/pages/register.tsx
@@ -1,6 +1,6 @@
import { IS_CLOUD, isAdminPresent, validateRequest } from "@dokploy/server";
import { standardSchemaResolver as zodResolver } from "@hookform/resolvers/standard-schema";
-import { createServerSideHelpers } from "@trpc/react-query/server";
+import { generateServerSideHelper } from "@/utils/create-server-helpers";
import { AlertTriangle } from "lucide-react";
import type { GetServerSidePropsContext } from "next";
import Link from "next/link";
@@ -8,7 +8,6 @@ import { useRouter } from "next/router";
import { type ReactElement, useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
-import superjson from "superjson";
import { z } from "zod";
import { OnboardingLayout } from "@/components/layouts/onboarding-layout";
import { SignInWithGithub } from "@/components/proprietary/auth/sign-in-with-github";
@@ -308,17 +307,7 @@ Register.getLayout = (page: ReactElement) => {
);
};
export async function getServerSideProps(context: GetServerSidePropsContext) {
- const helpers = createServerSideHelpers({
- router: appRouter,
- ctx: {
- req: context.req as any,
- res: context.res as any,
- db: null as any,
- session: null as any,
- user: null as any,
- },
- transformer: superjson,
- });
+ const helpers = generateServerSideHelper(appRouter, context);
// Prefetch the public branding so the onboarding logo and app name render
// correctly on the server (no flash of default branding).
await helpers.whitelabeling.getPublic.prefetch();
diff --git a/apps/dokploy/pages/send-reset-password.tsx b/apps/dokploy/pages/send-reset-password.tsx
index 5fbedb5ec..2f41e50c9 100644
--- a/apps/dokploy/pages/send-reset-password.tsx
+++ b/apps/dokploy/pages/send-reset-password.tsx
@@ -1,13 +1,12 @@
import { IS_CLOUD } from "@dokploy/server";
import { standardSchemaResolver as zodResolver } from "@hookform/resolvers/standard-schema";
-import { createServerSideHelpers } from "@trpc/react-query/server";
+import { generateServerSideHelper } from "@/utils/create-server-helpers";
import type { GetServerSidePropsContext } from "next";
import Link from "next/link";
import { useRouter } from "next/router";
import { type ReactElement, useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
-import superjson from "superjson";
import { z } from "zod";
import { OnboardingLayout } from "@/components/layouts/onboarding-layout";
import { AlertBlock } from "@/components/shared/alert-block";
@@ -178,17 +177,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
};
}
- const helpers = createServerSideHelpers({
- router: appRouter,
- ctx: {
- req: context.req as any,
- res: context.res as any,
- db: null as any,
- session: null as any,
- user: null as any,
- },
- transformer: superjson,
- });
+ const helpers = generateServerSideHelper(appRouter, context);
// Prefetch the public branding so the logo and app name render
// correctly on the server (no flash of default branding).
await helpers.whitelabeling.getPublic.prefetch();
diff --git a/apps/dokploy/utils/create-server-helpers.ts b/apps/dokploy/utils/create-server-helpers.ts
new file mode 100644
index 000000000..429bc67cf
--- /dev/null
+++ b/apps/dokploy/utils/create-server-helpers.ts
@@ -0,0 +1,21 @@
+import { createServerSideHelpers } from "@trpc/react-query/server";
+import type { GetServerSidePropsContext } from "next";
+import superjson from "superjson";
+import type { AppRouter } from "@/server/api/root";
+
+export const generateServerSideHelper = (
+ router: AppRouter,
+ context: GetServerSidePropsContext,
+) => {
+ return createServerSideHelpers({
+ router,
+ ctx: {
+ req: context.req as any,
+ res: context.res as any,
+ db: null as any,
+ session: null as any,
+ user: null as any,
+ },
+ transformer: superjson,
+ });
+};