From bca6af77fd3dcba1bd8b13dd7375ecc7d45142cd Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 6 Apr 2025 02:37:15 -0600 Subject: [PATCH] fix(traefik): update server configuration to use new host parameter and ensure HTTPS is set correctly - Modified the updateServerTraefik function to utilize the newHost parameter instead of user.host. - Ensured the HTTPS field is correctly initialized in the test for server configuration. --- .../__test__/traefik/server/update-server-config.test.ts | 2 +- packages/server/src/utils/traefik/web-server.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/dokploy/__test__/traefik/server/update-server-config.test.ts b/apps/dokploy/__test__/traefik/server/update-server-config.test.ts index bb31f4b2..201aee1e 100644 --- a/apps/dokploy/__test__/traefik/server/update-server-config.test.ts +++ b/apps/dokploy/__test__/traefik/server/update-server-config.test.ts @@ -74,7 +74,6 @@ beforeEach(() => { test("Should read the configuration file", () => { const config: FileConfig = loadOrCreateConfig("dokploy"); - expect(config.http?.routers?.["dokploy-router-app"]?.service).toBe( "dokploy-service-app", ); @@ -84,6 +83,7 @@ test("Should apply redirect-to-https", () => { updateServerTraefik( { ...baseAdmin, + https: true, certificateType: "letsencrypt", }, "example.com", diff --git a/packages/server/src/utils/traefik/web-server.ts b/packages/server/src/utils/traefik/web-server.ts index a5a59ee5..2a997147 100644 --- a/packages/server/src/utils/traefik/web-server.ts +++ b/packages/server/src/utils/traefik/web-server.ts @@ -15,7 +15,7 @@ export const updateServerTraefik = ( user: User | null, newHost: string | null, ) => { - const { https, host, certificateType } = user || {}; + const { https, certificateType } = user || {}; const appName = "dokploy"; const config: FileConfig = loadOrCreateConfig(appName); @@ -24,7 +24,7 @@ export const updateServerTraefik = ( config.http.services = config.http.services || {}; const currentRouterConfig = config.http.routers[`${appName}-router-app`] || { - rule: `Host(\`${host}\`)`, + rule: `Host(\`${newHost}\`)`, service: `${appName}-service-app`, entryPoints: ["web"], }; @@ -66,7 +66,7 @@ export const updateServerTraefik = ( currentRouterConfig.middlewares = []; } - if (user?.host) { + if (newHost) { writeTraefikConfig(config, appName); } else { removeTraefikConfig(appName);