Fix .env loading for dev-backend: check parent dir when in backend/
This commit is contained in:
parent
6e3d63f9c2
commit
44dea14885
2 changed files with 5 additions and 2 deletions
|
|
@ -62,7 +62,10 @@ func Load() *Config {
|
|||
// Load .env file if it exists.
|
||||
// This is for local development convenience.
|
||||
// In production, use environment variables directly.
|
||||
godotenv.Load(".env")
|
||||
// Try current dir first, then parent (for when running from backend/).
|
||||
if err := godotenv.Load(".env"); err != nil {
|
||||
godotenv.Load("../.env")
|
||||
}
|
||||
|
||||
// Return a new Config struct with all values.
|
||||
// getEnv(key, default) returns the environment variable value,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue