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
|
var appKey []byte
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var port string
|
port := "8080"
|
||||||
|
|
||||||
err := godotenv.Load()
|
godotenv.Load()
|
||||||
if err != nil {
|
|
||||||
port = "8080"
|
if p := os.Getenv("PORT"); p != "" {
|
||||||
|
port = p
|
||||||
}
|
}
|
||||||
|
|
||||||
port = os.Getenv("PORT")
|
|
||||||
appKey = []byte(os.Getenv("APP_KEY"))
|
appKey = []byte(os.Getenv("APP_KEY"))
|
||||||
if len(appKey) == 0 {
|
if len(appKey) == 0 {
|
||||||
log.Fatal("unable to load APP_KEY")
|
log.Fatal("unable to load APP_KEY")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue