Skip to content

Commit

Permalink
feat: add support both internal and public relay URL
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Nov 15, 2023
1 parent e49a5c8 commit ae6c55b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ ALBY_CLIENT_ID=
OAUTH_REDIRECT_URL=http://localhost:8080/alby/callback
COOKIE_SECRET=secretsecret
RELAY=wss://relay.getalby.com/v1
PUBLIC_RELAY=
PORT=8080
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ To build the CSS run:
- `NOSTR_PRIVKEY`: the private key of this service. Should be a securely randomly generated 32 byte hex string.
- `CLIENT_NOSTR_PUBKEY`: if set, this service will only listen to events authored by this public key. You can set this to your own nostr public key.
- `RELAY`: default: "wss://relay.getalby.com/v1"
- `PUBLIC_RELAY`: optional relay URL to be used in connection strings if `RELAY` is an internal URL
- `LN_BACKEND_TYPE`: ALBY or LND
- `ALBY_CLIENT_SECRET`= Alby OAuth client secret (used with the Alby backend)
- `ALBY_CLIENT_ID`= Alby OAuth client ID (used with the Alby backend)
Expand Down
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Config struct {
CookieDomain string `envconfig:"COOKIE_DOMAIN"`
ClientPubkey string `envconfig:"CLIENT_NOSTR_PUBKEY"`
Relay string `envconfig:"RELAY" default:"wss://relay.getalby.com/v1"`
PublicRelay string `envconfig:"PUBLIC_RELAY"`
LNBackendType string `envconfig:"LN_BACKEND_TYPE" default:"ALBY"`
LNDAddress string `envconfig:"LND_ADDRESS"`
LNDCertFile string `envconfig:"LND_CERT_FILE"`
Expand Down
7 changes: 4 additions & 3 deletions echo_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,10 @@ func (svc *Service) AppsCreateHandler(c echo.Context) error {
return c.Redirect(302, "/apps")
}

// FIXME: need a public-facing relay URL env variable
// and fallback to svc.cfg.Relay (hosted instance uses an internal URL)
publicRelayUrl := "wss://relay.getalby.com/v1";
publicRelayUrl := svc.cfg.PublicRelay;
if (publicRelayUrl == "") {
publicRelayUrl = svc.cfg.Relay;
}

if c.FormValue("returnTo") != "" {
returnToUrl, err := url.Parse(c.FormValue("returnTo"))
Expand Down

0 comments on commit ae6c55b

Please sign in to comment.