fix(settings): simplify letsEncryptEmail assignment and ensure router rule is always updated with new host

This commit is contained in:
Mauricio Siu
2025-12-07 20:03:54 -06:00
parent 22e6a06426
commit 28f40066a2
2 changed files with 9 additions and 4 deletions
+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,
}); });
@@ -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 = {