diff --git a/.env.example b/.env.example index a506cad..3a17d15 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ CORS_ORIGINS=http://localhost:5173,http://example.com DATABASE_URL=postgres://postgres:postgres@localhost:5432/your_db_name OTEL_ENABLED=false +PORT=8080 diff --git a/main.go b/main.go index a70b1c5..d0628eb 100644 --- a/main.go +++ b/main.go @@ -45,6 +45,10 @@ func initAndServe(ctx context.Context) int { corsOrigins := strings.Split(corsOriginString, ",") dbURL := mustEnv("DATABASE_URL") otelEnabled := os.Getenv("OTEL_ENABLED") == "true" + port := os.Getenv("PORT") + if port == "" { + port = "8080" + } frontendIndex, err := fs.Sub(ui.Index, "dist") if err != nil { @@ -93,7 +97,7 @@ func initAndServe(ctx context.Context) int { wrappedHandler := sloghttp.NewWithConfig(logger, config)(corsHandler.Handler(logHandler)) srv := &http.Server{ - Addr: ":8080", + Addr: ":" + port, Handler: wrappedHandler, ReadHeaderTimeout: 5 * time.Second, }