Skip to content

Local dev relay URL auto-detection is fragile #102

@intendednull

Description

@intendednull

Problem

The web app auto-detects a local relay in init.js by checking location.hostname:

if (!window.__WILLOW_RELAY_URL && (h === '127.0.0.1' || h === 'localhost')) {
    window.__WILLOW_RELAY_URL = 'http://' + h + ':3340';
}

This hardcodes port 3340 and only works for localhost. It also requires a separate init.js file copied by trunk because inline scripts in index.html get stripped during trunk processing.

Better Approach

Options:

  1. Trunk environment variables — use data-trunk attributes or build-time env vars to inject the relay URL at build time
  2. Runtime config endpoint — serve a /config.json from trunk or the relay that the app fetches on startup
  3. Query parameter — support ?relay=http://... for ad-hoc testing

The DEFAULT_RELAY_URL constant in app.rs should also be updated when the production relay infrastructure changes — currently it points to https://willow.intendednull.com:9443 which uses the old multiaddr format constant.

Files

  • crates/web/init.js — hardcoded port 3340
  • crates/web/src/app.rsresolve_relay_url() reads window.__WILLOW_RELAY_URL

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions