From f1cd94b17e9c0ebcc831cf4dc8b404483da81466 Mon Sep 17 00:00:00 2001 From: Worph Date: Sun, 14 Jun 2026 18:47:28 +0200 Subject: [PATCH] bugfix advertise url --- internal/config/config.go | 2 ++ internal/discovery/service.go | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 7c3d0d7..4606229 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -17,6 +17,7 @@ type Config struct { ServiceVersion string // Service version (default: "1.0.0") APIPort int // Service HTTP port (for leader info) BaseURL string // Base URL for stable service discovery + PublicURL string // Browser-facing URL for the service-bar nav; overrides BaseURL when set (e.g. a debug-direct port with no Caddy in front) // Redis configuration RedisPort int // Redis port (default: 6379) @@ -50,6 +51,7 @@ func Load() *Config { ServiceVersion: getEnv("SERVICE_VERSION", "1.0.0"), APIPort: getEnvInt("API_PORT", 8180), BaseURL: getEnv("BASE_URL", ""), + PublicURL: getEnv("META_CORE_PUBLIC_URL", ""), RedisPort: getEnvInt("REDIS_PORT", 6379), HTTPPort: getEnvInt("META_CORE_HTTP_PORT", 9000), HTTPHost: getEnv("META_CORE_HTTP_HOST", "127.0.0.1"), diff --git a/internal/discovery/service.go b/internal/discovery/service.go index 90c854a..84d42d8 100644 --- a/internal/discovery/service.go +++ b/internal/discovery/service.go @@ -87,9 +87,13 @@ func (s *Service) buildServiceInfo() *ServiceInfo { hostname, _ := os.Hostname() ip := getLocalIP() - // Use BASE_URL for external access, fall back to internal IP + // Browser-facing nav URL: prefer META_CORE_PUBLIC_URL (the reachable URL + // when there's no Caddy perimeter in front — e.g. a debug-direct port), + // then BASE_URL (the Caddy perimeter URL), then the internal IP. var baseUrl string - if s.config.BaseURL != "" { + if s.config.PublicURL != "" { + baseUrl = s.config.PublicURL + } else if s.config.BaseURL != "" { baseUrl = s.config.BaseURL } else { baseUrl = fmt.Sprintf("http://%s:%d", ip, s.config.APIPort)