diff --git a/src/auth.go b/src/auth.go index 2d449a1..969acc9 100644 --- a/src/auth.go +++ b/src/auth.go @@ -32,7 +32,7 @@ func lnAuth() (*LnAuth, error) { return nil, fmt.Errorf("rand.Read error: %w", err) } k1hex := hex.EncodeToString(k1) - url := []byte(fmt.Sprintf("https://delphi.market/api/login?tag=login&k1=%s&action=login", k1hex)) + url := []byte(fmt.Sprintf("https://%s/api/login?tag=login&k1=%s&action=login", PUBLIC_URL, k1hex)) conv, err := bech32.ConvertBits(url, 8, 5, true) if err != nil { return nil, fmt.Errorf("bech32.ConvertBits error: %w", err) diff --git a/src/router.go b/src/router.go index 6aefe20..3007c76 100644 --- a/src/router.go +++ b/src/router.go @@ -43,7 +43,7 @@ func login(c echo.Context) error { return err } qr := base64.StdEncoding.EncodeToString([]byte(png)) - return c.Render(http.StatusOK, "login.html", map[string]any{"session": c.Get("session"), "lnurl": lnauth.lnurl, "qr": qr}) + return c.Render(http.StatusOK, "login.html", map[string]any{"session": c.Get("session"), "PUBLIC_URL": PUBLIC_URL, "lnurl": lnauth.lnurl, "qr": qr}) } func verifyLogin(c echo.Context) error { diff --git a/src/server.go b/src/server.go index b0481aa..bdbbad9 100644 --- a/src/server.go +++ b/src/server.go @@ -21,6 +21,7 @@ var ( COMMIT_SHORT_SHA string VERSION string PORT int + PUBLIC_URL string ) func execCmd(name string, args ...string) string { @@ -37,6 +38,7 @@ func init() { if err != nil { log.Fatal("Error loading .env file") } + flag.StringVar(&PUBLIC_URL, "PUBLIC_URL", "delphi.market", "Public URL of website") flag.IntVar(&PORT, "PORT", 4321, "Server port") flag.Parse() e = echo.New() @@ -47,6 +49,7 @@ func init() { COMMIT_SHORT_SHA = execCmd("git", "rev-parse", "--short", "HEAD") VERSION = fmt.Sprintf("v0.0.0+%s", COMMIT_SHORT_SHA) log.Printf("Running commit %s", COMMIT_SHORT_SHA) + log.Printf("Public URL: %s", PUBLIC_URL) } func main() { diff --git a/template/login.html b/template/login.html index d0d91f6..d2f868f 100644 --- a/template/login.html +++ b/template/login.html @@ -64,7 +64,7 @@ const redirect = setInterval(() => { countdown.textContent = `Redirecting in ${timer--} ...` if (timer === -1) { - window.location.href = "https://delphi.market/"; + window.location.href = "https://{{.PUBLIC_URL}}/"; } }, 1000) }