feat: make invite link base URL configurable via APP_URL

Load environment variables from .env file using godotenv.
Defaults to https://demo.adriatica.io if APP_URL is not set.
This commit is contained in:
Ryan Hamamura
2026-02-04 07:02:52 -10:00
parent 20ed4807d9
commit 7faf94fa6d
7 changed files with 23 additions and 4 deletions

View File

@@ -130,7 +130,7 @@ func SnakePlayerList(sg *snake.SnakeGame, mySlot int) h.H {
}
func SnakeInviteLink(gameID string) h.H {
fullURL := baseURL + "/snake/" + gameID
fullURL := getBaseURL() + "/snake/" + gameID
return h.Div(h.Class("mt-4 text-center"),
h.P(h.Text("Share this link to invite players:")),
h.Div(h.Class("bg-base-200 p-4 rounded-lg font-mono break-all my-2"),

View File

@@ -1,6 +1,8 @@
package ui
import (
"os"
"github.com/ryanhamamura/c4/game"
"github.com/ryanhamamura/via/h"
)
@@ -115,10 +117,15 @@ func PlayerInfo(g *game.Game, myColor int) h.H {
)
}
const baseURL = "https://demo.adriatica.io"
func getBaseURL() string {
if url := os.Getenv("APP_URL"); url != "" {
return url
}
return "https://demo.adriatica.io"
}
func InviteLink(gameID string) h.H {
fullURL := baseURL + "/game/" + gameID
fullURL := getBaseURL() + "/game/" + gameID
return h.Div(h.Class("mt-4 text-center"),
h.P(h.Text("Share this link with your opponent:")),
h.Div(h.Class("bg-base-200 p-4 rounded-lg font-mono break-all my-2"),