Skip to content

fix: serve real home page instead of redirecting, add templated pages#409

Open
CKodidela wants to merge 1 commit intocameri:mainfrom
CKodidela:fix/home-redirect-302
Open

fix: serve real home page instead of redirecting, add templated pages#409
CKodidela wants to merge 1 commit intocameri:mainfrom
CKodidela:fix/home-redirect-302

Conversation

@CKodidela
Copy link
Copy Markdown
Contributor

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.

Description

Replaces the broken home page behaviour with a proper templated home page. All five templates (index.html,
get-invoice.html, post-invoice.html, terms.html, privacy.html) are user-modifiable files in resources/. The
home page conditionally shows or hides the admission fee section using CSS class template variables, so it works
correctly whether payments are enabled or not.

Related Issue

Closes #269

Motivation and Context

The 301 redirect was a bug browsers cache it permanently, so any future change to the home page would be invisible
to returning visitors until they manually cleared their cache. Beyond the redirect fix, relay operators (especially
those running private/whitelist-only relays with no payments) had no home page at all, and there was no privacy policy
page despite many jurisdictions requiring one.

How Has This Been Tested?

Manually verified both payment-enabled and payment-disabled paths render the correct home page content. Verified GET /invoices serves get-invoice.html, POST /invoices serves post-invoice.html, GET /terms and GET /privacy
both render correctly. Confirmed application/nostr+json requests to / still return the relay information document
unchanged.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • All new and existing tests passed.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User-modifiable templates need work

1 participant