Add PUBLIC_URL env var
This commit is contained in:
parent
eb977576db
commit
fbab0b4975
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue