diff --git a/internal/api/handlers.go b/internal/api/handlers.go index c031692..41cc722 100644 --- a/internal/api/handlers.go +++ b/internal/api/handlers.go @@ -4196,8 +4196,11 @@ func (g *Gateway) calculateWebTorrentPieceLength(fileSize int64) int64 { // getBaseURL returns the base URL for the gateway func (g *Gateway) getBaseURL() string { - // TODO: This should be configurable or detected from request - // For now, use localhost with the configured port + // Use configured public URL if available, otherwise fall back to localhost + if g.publicURL != "" && g.publicURL != "http://localhost" { + return g.publicURL + } + // Fallback to localhost (for development) return fmt.Sprintf("http://localhost:%d", g.config.Gateway.Port) }