use default 0.0.0.0 only when running in docker
This commit is contained in:
parent
1f078f2682
commit
8cdf445ece
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"git.maronato.dev/maronato/goshort/internal/config"
|
||||
|
@ -38,7 +39,11 @@ func NewSharedCmdOptions() []ff.Option {
|
|||
|
||||
func RegisterBaseFlags(fs *flag.FlagSet, cfg *config.Config) {
|
||||
fs.BoolVar(&cfg.Debug, "debug", config.DefaultDebug, "enable debug mode")
|
||||
fs.StringVar(&cfg.Host, "host", config.DefaultHost, "host to listen on")
|
||||
var defaultHost = config.DefaultHost
|
||||
if os.Getenv("ENV_DOCKER") == "true" {
|
||||
defaultHost = "0.0.0.0"
|
||||
}
|
||||
fs.StringVar(&cfg.Host, "host", defaultHost, "host to listen on")
|
||||
fs.StringVar(&cfg.Port, "port", config.DefaultPort, "port to listen on")
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ const (
|
|||
DefaultDBURL = "goshort.db"
|
||||
// DefaultPort is the default port to listen on.
|
||||
DefaultPort = "8080"
|
||||
// DefaultHost is the default host to listen on.
|
||||
DefaultHost = "0.0.0.0"
|
||||
// DefaultHost is the default host to listen on. This is set to 0.0.0.0 when running in Docker.
|
||||
DefaultHost = "localhost"
|
||||
// DefaultUIPort is the default port to listen on for the UI.
|
||||
DefaultUIPort = "3000"
|
||||
// DefaultDebug is the default debug mode.
|
||||
|
|
Loading…
Reference in New Issue
Block a user