diff --git a/proxy/go.mod b/proxy/go.mod index 3782d6a..76c5712 100644 --- a/proxy/go.mod +++ b/proxy/go.mod @@ -8,4 +8,8 @@ require ( github.com/mattn/go-sqlite3 v1.14.28 ) -require github.com/felixge/httpsnoop v1.0.3 // indirect +require ( + github.com/felixge/httpsnoop v1.0.3 // indirect + github.com/joho/godotenv v1.5.1 // indirect + github.com/mattn/go-sqlite3 v1.14.28 // indirect +) diff --git a/proxy/go.sum b/proxy/go.sum index 7c0f91b..3a19b1d 100644 --- a/proxy/go.sum +++ b/proxy/go.sum @@ -4,5 +4,7 @@ github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyE github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A= github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= diff --git a/proxy/internal/config/config.go b/proxy/internal/config/config.go index 3e9619f..a9540c3 100644 --- a/proxy/internal/config/config.go +++ b/proxy/internal/config/config.go @@ -2,8 +2,11 @@ package config import ( "os" + "path/filepath" "strconv" "time" + + "github.com/joho/godotenv" ) type Config struct { @@ -31,6 +34,17 @@ type StorageConfig struct { } func Load() (*Config, error) { + // Load .env file if it exists + // Look for .env file in the project root (one level up from proxy/) + envPath := filepath.Join("..", ".env") + if err := godotenv.Load(envPath); err != nil { + // If .env doesn't exist in parent directory, try current directory + if err := godotenv.Load(".env"); err != nil { + // .env file is optional, so we just log and continue + // This allows the app to work with system environment variables only + } + } + cfg := &Config{ Server: ServerConfig{ Port: getEnv("PORT", "3001"),