From e13873035781280671c1e5b0213a814b259d1563 Mon Sep 17 00:00:00 2001 From: BROCODES2024 Date: Thu, 9 Apr 2026 08:31:42 +0530 Subject: [PATCH] fix: serve real home page instead of redirecting, add templated pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, visiting the relay's home page resulted in a 301 permanent redirect to /invoices when payments were enabled, or a bare text response when payments were disabled. Neither gave relay operators a real home page, and the 301 caused browsers to cache the redirect permanently — making it impossible to change home page behaviour later without users clearing cache. Changes: - / now always serves index.html, a proper home page that works with and without payments. When admission fees are enabled, a payment card and link to /invoices is shown; otherwise an "open relay" card is shown. Template variables: {{name}}, {{description}}, {{relay_url}}, {{amount}}, {{payments_section_class}}, {{no_payments_section_class}}, {{nonce}}. - The old index.html (admission fee form) is renamed to get-invoice.html, served by GET /invoices. The ToS link now points to /terms instead of an embedded modal. - The old invoices.html (payment result page) is renamed to post-invoice.html, served after POST /invoices. The rename reflects what the page actually is. - privacy.html template added and served at GET /privacy. - Old index.html and invoices.html remain in resources/ for reference. --- resources/get-invoice.html | 103 +++++++ resources/index.html | 192 ++++--------- resources/post-invoice.html | 272 ++++++++++++++++++ resources/privacy.html | 79 +++++ .../invoices/get-invoice-controller.ts | 2 +- .../invoices/post-invoice-controller.ts | 2 +- .../get-privacy-request-handler.ts | 15 + .../request-handlers/root-request-handler.ts | 24 +- src/routes/index.ts | 2 + 9 files changed, 545 insertions(+), 146 deletions(-) create mode 100644 resources/get-invoice.html create mode 100644 resources/post-invoice.html create mode 100644 resources/privacy.html create mode 100644 src/handlers/request-handlers/get-privacy-request-handler.ts diff --git a/resources/get-invoice.html b/resources/get-invoice.html new file mode 100644 index 00000000..9b600c76 --- /dev/null +++ b/resources/get-invoice.html @@ -0,0 +1,103 @@ + + + + + + Admission Fee Required - {{name}} + + + + +
+
+
+
+

{{name}}

+
+
+
+
+
+
+

+ This Nostr relay requires a one-time + admission + fee.
Once payment is complete, you will be able to post and fetch events from this relay. +

+
+
+

+ Provide your Nostr public key to generate a Bitcoin Lightning invoice. +

+
+
+
+
+
+
+
+
+ + +
+ Hex or npub formats accepted. +
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + + +
+
+
+
+ + + + diff --git a/resources/index.html b/resources/index.html index e22fef48..115ce4be 100644 --- a/resources/index.html +++ b/resources/index.html @@ -3,161 +3,79 @@ - Admission Fee Required - {{name}} + {{name}}
-
-
-
-

{{name}}

-
+
+
+

{{name}}

-
-
-
-
-

- This Nostr relay requires a one-time - admission - fee.
Once payment is complete, you will be able to post and fetch events from this relay. -

-
-
-

- Provide your Nostr public key to generate a Bitcoin Lightning invoice. -

-
-
-
+
+
+
+

{{description}}

-
-
+
+ +
+
+ + +
-
- - -
- Hex or npub formats accepted. -
-
-
- - -
+
Nostr Relay
+

+ This is a Nostr relay. + To use it, connect with a Nostr client using the address below. +

+

+ Relay address:
+ {{relay_url}} +

-
-
-
- - -
-
-
-
- - - -
-
- -
-