Merge pull request #2717 from Omar125X/fix/domain-validation

fix: improve domain and letsencrypt email validation
This commit is contained in:
Mauricio Siu
2025-12-07 20:07:46 -06:00
committed by GitHub
4 changed files with 15 additions and 8 deletions
@@ -36,7 +36,7 @@ import { api } from "@/utils/api";
const addServerDomain = z const addServerDomain = z
.object({ .object({
domain: z.string(), domain: z.string().trim().toLowerCase(),
letsEncryptEmail: z.string(), letsEncryptEmail: z.string(),
https: z.boolean().optional(), https: z.boolean().optional(),
certificateType: z.enum(["letsencrypt", "none", "custom"]), certificateType: z.enum(["letsencrypt", "none", "custom"]),
@@ -49,7 +49,11 @@ const addServerDomain = z
message: "Required", message: "Required",
}); });
} }
if (data.certificateType === "letsencrypt" && !data.letsEncryptEmail) { if (
data.https &&
data.certificateType === "letsencrypt" &&
!data.letsEncryptEmail
) {
ctx.addIssue({ ctx.addIssue({
code: z.ZodIssueCode.custom, code: z.ZodIssueCode.custom,
message: message:
+1 -3
View File
@@ -225,9 +225,7 @@ export const settingsRouter = createTRPCRouter({
} }
const user = await updateUser(ctx.user.ownerId, { const user = await updateUser(ctx.user.ownerId, {
host: input.host, host: input.host,
...(input.letsEncryptEmail && { letsEncryptEmail: input.letsEncryptEmail,
letsEncryptEmail: input.letsEncryptEmail,
}),
certificateType: input.certificateType, certificateType: input.certificateType,
https: input.https, https: input.https,
}); });
-2
View File
@@ -127,8 +127,6 @@ const { handler, api } = betterAuth({
}); });
} }
console.log(user);
if (IS_CLOUD) { if (IS_CLOUD) {
try { try {
const hutk = getHubSpotUTK( const hutk = getHubSpotUTK(
@@ -23,11 +23,18 @@ export const updateServerTraefik = (
config.http.routers = config.http.routers || {}; config.http.routers = config.http.routers || {};
config.http.services = config.http.services || {}; 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`] || { const currentRouterConfig = config.http.routers[`${appName}-router-app`] || {
rule: `Host(\`${newHost}\`)`,
service: `${appName}-service-app`, service: `${appName}-service-app`,
entryPoints: ["web"], 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.routers[`${appName}-router-app`] = currentRouterConfig;
config.http.services = { config.http.services = {