From e097467c958a94adc50ebd23a2b61fa92c3ce485 Mon Sep 17 00:00:00 2001 From: KodekaTeam Date: Sat, 22 Aug 2026 00:56:24 +0700 Subject: [PATCH] fix(domains): improve shared Nginx reconciliation logic in domain routes --- next.config.ts | 7 +++++++ src/server/routes/domains.ts | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/next.config.ts b/next.config.ts index dee4da3..35b45ce 100644 --- a/next.config.ts +++ b/next.config.ts @@ -41,6 +41,13 @@ const securityHeaders = [ const nextConfig: NextConfig = { allowedDevOrigins: ["localhost", "127.0.0.1", "192.168.12.11"], devIndicators: false, + experimental: { + // Domain provisioning can include SSH, Nginx validation/reload, and + // Certbot work. Keep the same-origin rewrite alive long enough for the + // backend to return its structured result instead of a proxy-generated + // non-JSON 500 response. + proxyTimeout: 5 * 60 * 1000, + }, async rewrites() { const backendUrl = process.env.INTERNAL_API_URL || diff --git a/src/server/routes/domains.ts b/src/server/routes/domains.ts index fd1374e..31c462e 100644 --- a/src/server/routes/domains.ts +++ b/src/server/routes/domains.ts @@ -1837,8 +1837,13 @@ export async function domainRoutes(app: FastifyInstance) { const willBeSharedNginx = isSharedNginxConfig(nextInput); const previousRootDomain = getDomainConfigAnchor([existing.name]); const nextRootDomain = getDomainConfigAnchor([nextInput.name]); - const previousSharedGroupNames = + const shouldReconcilePreviousShared = wasSharedNginx && + (!willBeSharedNginx || + existing.serverId !== (nextInput.serverId ?? null) || + previousRootDomain !== nextRootDomain); + const previousSharedGroupNames = + shouldReconcilePreviousShared && existing.serverId && existing.targetContainerId && existing.targetPort @@ -1938,7 +1943,7 @@ export async function domainRoutes(app: FastifyInstance) { }); if ( - wasSharedNginx && + shouldReconcilePreviousShared && existing.serverId && existing.targetContainerId && existing.targetPort