Files
temetro/backend/docker-compose.tunnel.yml
T
Khalid Abdi a68b7f2573 fix(backend): make tunnel relay reachable before baking it into QR
Two changes so off-network wallet scanning actually works:

- Force the cloudflared edge connection over http2 (TCP/443) instead of
  QUIC (UDP/7844) in both the Docker tunnel and the dev-tunnel script.
  QUIC is blocked on many networks/Docker setups, which left the tunnel
  stuck "Failed to dial a quic connection" and the QR pointing at a dead
  URL — the root cause of "must be on the same network" failures.
- Gate the discovered quick-tunnel URL on real end-to-end reachability:
  poll the tunnel's own /health until it answers (Cloudflare 1033 clears
  in ~30s) before publishing it, and have /pair await that discovery so
  the QR never carries a not-yet-live URL.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 23:56:29 +03:00

28 lines
1.2 KiB
YAML

# Overlay that adds a public Cloudflare tunnel so a patient's phone can scan the
# wallet-import QR from ANY network (cellular, other Wi-Fi) — not just the LAN.
#
# npm run docker:tunnel # from backend/ (easiest)
# # equivalently:
# docker compose -f docker-compose.yml -f docker-compose.tunnel.yml up --build
#
# cloudflared opens a random https://<id>.trycloudflare.com URL to the backend
# and exposes it on its metrics endpoint; the backend reads it from there and
# bakes it into the QR (CLOUDFLARED_METRICS_URL below). Zero config — no
# Cloudflare account or token needed for these quick tunnels.
services:
cloudflared:
image: cloudflare/cloudflared:latest
restart: unless-stopped
depends_on:
- backend
# --protocol http2 forces the edge connection over TCP/443 instead of QUIC
# (UDP/7844), which is blocked on many networks/Docker setups and otherwise
# leaves the tunnel stuck "Failed to dial a quic connection".
command: tunnel --no-autoupdate --protocol http2 --url http://backend:4000 --metrics 0.0.0.0:3333
backend:
environment:
# Where the backend reads its public quick-tunnel URL from.
CLOUDFLARED_METRICS_URL: http://cloudflared:3333