This commit is contained in:
@@ -17,6 +17,7 @@ type Config struct {
|
|||||||
ServiceVersion string // Service version (default: "1.0.0")
|
ServiceVersion string // Service version (default: "1.0.0")
|
||||||
APIPort int // Service HTTP port (for leader info)
|
APIPort int // Service HTTP port (for leader info)
|
||||||
BaseURL string // Base URL for stable service discovery
|
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
|
// Redis configuration
|
||||||
RedisPort int // Redis port (default: 6379)
|
RedisPort int // Redis port (default: 6379)
|
||||||
@@ -50,6 +51,7 @@ func Load() *Config {
|
|||||||
ServiceVersion: getEnv("SERVICE_VERSION", "1.0.0"),
|
ServiceVersion: getEnv("SERVICE_VERSION", "1.0.0"),
|
||||||
APIPort: getEnvInt("API_PORT", 8180),
|
APIPort: getEnvInt("API_PORT", 8180),
|
||||||
BaseURL: getEnv("BASE_URL", ""),
|
BaseURL: getEnv("BASE_URL", ""),
|
||||||
|
PublicURL: getEnv("META_CORE_PUBLIC_URL", ""),
|
||||||
RedisPort: getEnvInt("REDIS_PORT", 6379),
|
RedisPort: getEnvInt("REDIS_PORT", 6379),
|
||||||
HTTPPort: getEnvInt("META_CORE_HTTP_PORT", 9000),
|
HTTPPort: getEnvInt("META_CORE_HTTP_PORT", 9000),
|
||||||
HTTPHost: getEnv("META_CORE_HTTP_HOST", "127.0.0.1"),
|
HTTPHost: getEnv("META_CORE_HTTP_HOST", "127.0.0.1"),
|
||||||
|
|||||||
@@ -87,9 +87,13 @@ func (s *Service) buildServiceInfo() *ServiceInfo {
|
|||||||
hostname, _ := os.Hostname()
|
hostname, _ := os.Hostname()
|
||||||
ip := getLocalIP()
|
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
|
var baseUrl string
|
||||||
if s.config.BaseURL != "" {
|
if s.config.PublicURL != "" {
|
||||||
|
baseUrl = s.config.PublicURL
|
||||||
|
} else if s.config.BaseURL != "" {
|
||||||
baseUrl = s.config.BaseURL
|
baseUrl = s.config.BaseURL
|
||||||
} else {
|
} else {
|
||||||
baseUrl = fmt.Sprintf("http://%s:%d", ip, s.config.APIPort)
|
baseUrl = fmt.Sprintf("http://%s:%d", ip, s.config.APIPort)
|
||||||
|
|||||||
Reference in New Issue
Block a user