From 8ba4ac22cca7eec0a1ff2654a9d2714b0204b37f Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Wed, 30 Apr 2025 01:23:54 -0600 Subject: [PATCH] Enhance domain validation feedback in ShowDomains and AddDomain components. Add descriptive tooltips for container port input and improve validation state messaging to indicate Cloudflare status. Remove unnecessary console logs for cleaner code. --- .../application/domains/add-domain.tsx | 7 ++++-- .../application/domains/show-domains.tsx | 5 +++- .../dashboard/compose/domains/add-domain.tsx | 5 ++++ .../compose/domains/show-domains.tsx | 23 ++++++++++++++++--- packages/server/src/services/domain.ts | 17 +++++++------- 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/apps/dokploy/components/dashboard/application/domains/add-domain.tsx b/apps/dokploy/components/dashboard/application/domains/add-domain.tsx index 8da85a879..e5e4d7998 100644 --- a/apps/dokploy/components/dashboard/application/domains/add-domain.tsx +++ b/apps/dokploy/components/dashboard/application/domains/add-domain.tsx @@ -89,8 +89,6 @@ export const AddDomain = ({ serverId: application?.serverId || "", }); - console.log("canGenerateTraefikMeDomains", canGenerateTraefikMeDomains); - const form = useForm({ resolver: zodResolver(domain), defaultValues: { @@ -276,6 +274,11 @@ export const AddDomain = ({ return ( Container Port + + The port where your application is running inside the + container (e.g., 3000 for Node.js, 80 for Nginx, 8080 + for Java) + diff --git a/apps/dokploy/components/dashboard/application/domains/show-domains.tsx b/apps/dokploy/components/dashboard/application/domains/show-domains.tsx index c62f1c747..5e29f145d 100644 --- a/apps/dokploy/components/dashboard/application/domains/show-domains.tsx +++ b/apps/dokploy/components/dashboard/application/domains/show-domains.tsx @@ -84,6 +84,7 @@ export const ShowDomains = ({ applicationId }: Props) => { isValid: result.isValid, error: result.error, resolvedIp: result.resolvedIp, + message: result.error && result.isValid ? result.error : undefined, }, })); } catch (err) { @@ -304,7 +305,9 @@ export const ShowDomains = ({ applicationId }: Props) => { ) : validationState?.isValid ? ( <> - {"DNS Valid"} + {validationState.message + ? "Behind Cloudflare" + : "DNS Valid"} ) : validationState?.error ? ( <> diff --git a/apps/dokploy/components/dashboard/compose/domains/add-domain.tsx b/apps/dokploy/components/dashboard/compose/domains/add-domain.tsx index 6089c99ff..9f08296e5 100644 --- a/apps/dokploy/components/dashboard/compose/domains/add-domain.tsx +++ b/apps/dokploy/components/dashboard/compose/domains/add-domain.tsx @@ -401,6 +401,11 @@ export const AddDomainCompose = ({ return ( Container Port + + The port where your application is running inside the + container (e.g., 3000 for Node.js, 80 for Nginx, 8080 + for Java) + diff --git a/apps/dokploy/components/dashboard/compose/domains/show-domains.tsx b/apps/dokploy/components/dashboard/compose/domains/show-domains.tsx index 85ae3d9a1..d5b876aa4 100644 --- a/apps/dokploy/components/dashboard/compose/domains/show-domains.tsx +++ b/apps/dokploy/components/dashboard/compose/domains/show-domains.tsx @@ -42,6 +42,7 @@ export type ValidationState = { isValid?: boolean; error?: string; resolvedIp?: string; + message?: string; }; export type ValidationStates = { @@ -98,6 +99,7 @@ export const ShowDomainsCompose = ({ composeId }: Props) => { isValid: result.isValid, error: result.error, resolvedIp: result.resolvedIp, + message: result.error && result.isValid ? result.error : undefined, }, })); } catch (err) { @@ -322,12 +324,14 @@ export const ShowDomainsCompose = ({ composeId }: Props) => { ) : validationState?.isValid ? ( <> - {"DNS Valid"} + {validationState.message + ? "Behind Cloudflare" + : "DNS Valid"} ) : validationState?.error ? ( <> - {validationState.error} + DNS Invalid ) : ( <> @@ -338,13 +342,26 @@ export const ShowDomainsCompose = ({ composeId }: Props) => { - {validationState?.error ? ( + {validationState?.error && + !validationState.isValid ? (

Error:

{validationState.error}

+ ) : validationState?.isValid ? ( +
+

+ {validationState.message + ? "Info:" + : "Valid Configuration:"} +

+

+ {validationState.message || + `Domain points to ${validationState.resolvedIp}`} +

+
) : ( "Click to validate DNS configuration" )} diff --git a/packages/server/src/services/domain.ts b/packages/server/src/services/domain.ts index 4035b567c..1ce8f1993 100644 --- a/packages/server/src/services/domain.ts +++ b/packages/server/src/services/domain.ts @@ -180,7 +180,7 @@ export const validateDomain = async ( // Resolve the domain to get its IP const ips = await resolveDns(cleanDomain || ""); - const resolvedIp = ips[0]; + const resolvedIps = ips.map((ip) => ip.toString()); // Check if it's a Cloudflare IP const behindCloudflare = ips.some((ip) => isCloudflareIp(ip)); @@ -189,7 +189,7 @@ export const validateDomain = async ( if (behindCloudflare) { return { isValid: true, - resolvedIp, + resolvedIp: resolvedIps.join(", "), isCloudflare: true, error: "Domain is behind Cloudflare - actual IP is masked by Cloudflare proxy", @@ -199,19 +199,18 @@ export const validateDomain = async ( // If we have an expected IP, validate against it if (expectedIp) { return { - isValid: resolvedIp === expectedIp, - resolvedIp, - error: - resolvedIp !== expectedIp - ? `Domain resolves to ${resolvedIp} but should point to ${expectedIp}` - : undefined, + isValid: resolvedIps.includes(expectedIp), + resolvedIp: resolvedIps.join(", "), + error: !resolvedIps.includes(expectedIp) + ? `Domain resolves to ${resolvedIps.join(", ")} but should point to ${expectedIp}` + : undefined, }; } // If no expected IP, just return the resolved IP return { isValid: true, - resolvedIp, + resolvedIp: resolvedIps.join(", "), }; } catch (error) { return {