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:
@@ -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"),
|
||||
|
||||
11
ui/status.go
11
ui/status.go
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user