Fix PORT env var overwriting the 8080 fallback
The old code set port='8080' then unconditionally overwrote it with
os.Getenv("PORT"), which returns "" when unset, causing the server
to bind to ':' instead of ':8080'.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d48adbc3f5
commit
bda5ef1fcf
1 changed files with 5 additions and 6 deletions
|
|
@ -16,14 +16,13 @@ import (
|
|||
var appKey []byte
|
||||
|
||||
func main() {
|
||||
var port string
|
||||
port := "8080"
|
||||
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
port = "8080"
|
||||
godotenv.Load()
|
||||
|
||||
if p := os.Getenv("PORT"); p != "" {
|
||||
port = p
|
||||
}
|
||||
|
||||
port = os.Getenv("PORT")
|
||||
appKey = []byte(os.Getenv("APP_KEY"))
|
||||
if len(appKey) == 0 {
|
||||
log.Fatal("unable to load APP_KEY")
|
||||
|
|
|
|||
Loading…
Reference in a new issue