From 6e86fafa5e0373a53deccd1008242800021a321d Mon Sep 17 00:00:00 2001 From: Omar Elshenhabi Date: Mon, 29 Sep 2025 01:15:51 +0300 Subject: [PATCH 1/3] fix: improve domain and letsencrypt email validation --- .../dashboard/settings/web-domain.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/dokploy/components/dashboard/settings/web-domain.tsx b/apps/dokploy/components/dashboard/settings/web-domain.tsx index cafb95f53..fdf479816 100644 --- a/apps/dokploy/components/dashboard/settings/web-domain.tsx +++ b/apps/dokploy/components/dashboard/settings/web-domain.tsx @@ -33,9 +33,19 @@ import { import { Switch } from "@/components/ui/switch"; import { api } from "@/utils/api"; +const hostnameRegex = + /^(?=.{1,253}$)(?!-)[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\.(?!-)[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)+$/; + const addServerDomain = z .object({ - domain: z.string(), + domain: z + .string() + .trim() + .toLowerCase() + .regex( + hostnameRegex, + "Invalid hostname (no http://, no slash, no port).", + ), letsEncryptEmail: z.string(), https: z.boolean().optional(), certificateType: z.enum(["letsencrypt", "none", "custom"]), @@ -48,7 +58,11 @@ const addServerDomain = z message: "Required", }); } - if (data.certificateType === "letsencrypt" && !data.letsEncryptEmail) { + if ( + data.https && + data.certificateType === "letsencrypt" && + !data.letsEncryptEmail + ) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: From 28f40066a2b782dc60a98cd86c9f9412907e55e5 Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Sun, 7 Dec 2025 20:03:54 -0600 Subject: [PATCH 2/3] fix(settings): simplify letsEncryptEmail assignment and ensure router rule is always updated with new host --- apps/dokploy/server/api/routers/settings.ts | 4 +--- packages/server/src/utils/traefik/web-server.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/dokploy/server/api/routers/settings.ts b/apps/dokploy/server/api/routers/settings.ts index 5610e8d96..00584bf2d 100644 --- a/apps/dokploy/server/api/routers/settings.ts +++ b/apps/dokploy/server/api/routers/settings.ts @@ -225,9 +225,7 @@ export const settingsRouter = createTRPCRouter({ } const user = await updateUser(ctx.user.ownerId, { host: input.host, - ...(input.letsEncryptEmail && { - letsEncryptEmail: input.letsEncryptEmail, - }), + letsEncryptEmail: input.letsEncryptEmail, certificateType: input.certificateType, https: input.https, }); diff --git a/packages/server/src/utils/traefik/web-server.ts b/packages/server/src/utils/traefik/web-server.ts index 02472a583..0209d9a21 100644 --- a/packages/server/src/utils/traefik/web-server.ts +++ b/packages/server/src/utils/traefik/web-server.ts @@ -23,11 +23,18 @@ export const updateServerTraefik = ( config.http.routers = config.http.routers || {}; config.http.services = config.http.services || {}; + // Get or create router config, but always update the rule with newHost const currentRouterConfig = config.http.routers[`${appName}-router-app`] || { - rule: `Host(\`${newHost}\`)`, service: `${appName}-service-app`, entryPoints: ["web"], + rule: `Host(\`${newHost}\`)`, }; + + // Always update the rule with the new host + if (newHost) { + currentRouterConfig.rule = `Host(\`${newHost}\`)`; + } + config.http.routers[`${appName}-router-app`] = currentRouterConfig; config.http.services = { From d435553839edc66d5001b2135c445126f85722e1 Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Sun, 7 Dec 2025 20:06:54 -0600 Subject: [PATCH 3/3] chore(auth): remove debug log statement for user in authentication flow --- .../components/dashboard/settings/web-domain.tsx | 12 +----------- packages/server/src/lib/auth.ts | 2 -- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/apps/dokploy/components/dashboard/settings/web-domain.tsx b/apps/dokploy/components/dashboard/settings/web-domain.tsx index 31d810bd2..c889708c3 100644 --- a/apps/dokploy/components/dashboard/settings/web-domain.tsx +++ b/apps/dokploy/components/dashboard/settings/web-domain.tsx @@ -34,19 +34,9 @@ import { import { Switch } from "@/components/ui/switch"; import { api } from "@/utils/api"; -const hostnameRegex = - /^(?=.{1,253}$)(?!-)[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\.(?!-)[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)+$/; - const addServerDomain = z .object({ - domain: z - .string() - .trim() - .toLowerCase() - .regex( - hostnameRegex, - "Invalid hostname (no http://, no slash, no port).", - ), + domain: z.string().trim().toLowerCase(), letsEncryptEmail: z.string(), https: z.boolean().optional(), certificateType: z.enum(["letsencrypt", "none", "custom"]), diff --git a/packages/server/src/lib/auth.ts b/packages/server/src/lib/auth.ts index f1204596c..9c56a7d59 100644 --- a/packages/server/src/lib/auth.ts +++ b/packages/server/src/lib/auth.ts @@ -127,8 +127,6 @@ const { handler, api } = betterAuth({ }); } - console.log(user); - if (IS_CLOUD) { try { const hutk = getHubSpotUTK(