mirror of
https://github.com/sartoopjj/thefeed.git
synced 2026-05-19 05:04:35 +03:00
feat: add host flag to configure web UI listen address
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
+9
-2
@@ -15,6 +15,7 @@ import (
|
||||
func main() {
|
||||
dataDir := flag.String("data-dir", "./thefeeddata", "Data directory for config, cache, and sessions")
|
||||
port := flag.Int("port", 8080, "Web UI port")
|
||||
host := flag.String("host", "127.0.0.1", "Web UI listen address (host), use 0.0.0.0 to expose to LAN")
|
||||
password := flag.String("password", "", "Admin password for web UI (empty = no auth)")
|
||||
showVersion := flag.Bool("version", false, "Show version and exit")
|
||||
flag.Usage = func() {
|
||||
@@ -28,13 +29,19 @@ func main() {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
srv, err := web.New(*dataDir, *port, *password)
|
||||
srv, err := web.New(*dataDir, *port, *host, *password)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to start: %v", err)
|
||||
}
|
||||
|
||||
// Try to open browser automatically
|
||||
url := fmt.Sprintf("http://127.0.0.1:%d", *port)
|
||||
|
||||
// Open browser on the chosen host (localhost if default)
|
||||
browserHost := *host
|
||||
if browserHost == "0.0.0.0" {
|
||||
browserHost = "127.0.0.1"
|
||||
}
|
||||
url := fmt.Sprintf("http://%s:%d", browserHost, *port)
|
||||
go openBrowser(url)
|
||||
|
||||
if err := srv.Run(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user