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

View File

@@ -36,7 +36,7 @@ import { api } from "@/utils/api";
const addServerDomain = z
.object({
domain: z.string(),
domain: z.string().trim().toLowerCase(),
letsEncryptEmail: z.string(),
https: z.boolean().optional(),
certificateType: z.enum(["letsencrypt", "none", "custom"]),
@@ -49,7 +49,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:

View File

@@ -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,
});

View File

@@ -127,8 +127,6 @@ const { handler, api } = betterAuth({
});
}
console.log(user);
if (IS_CLOUD) {
try {
const hutk = getHubSpotUTK(

View File

@@ -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 = {