Serve /api/ws without Basic auth so the live feed connects #3

Merged
matitos merged 1 commits from fix/websocket-basic-auth into main 2026-09-19 15:11:18 +02:00
Owner

Problem

The dashboard showed "reconnecting": browsers don't reliably replay Basic-auth credentials on a WebSocket upgrade, so /api/ws was 401'd by Traefik and silently retried forever (only the 5s REST poll kept the UI current).

Fix

  • /api/ws gets its own higher-priority Traefik router without Basic auth.
  • The WS is still gated by API_TOKEN (nginx injects it on the handshake; backend also accepts ?token=).
  • Deploy fails closed unless CRYPTO_API_TOKEN is set.
  • nginx /api/ws block split out so upgrade headers are only set there.
  • Reconnect backoff 2s → 30s.

Testing

  • Backend: 79 tests pass (3 new WS auth cases: missing/header/query token), ruff clean.
  • Frontend: build + tests pass.
## Problem The dashboard showed **"reconnecting"**: browsers don't reliably replay Basic-auth credentials on a WebSocket upgrade, so `/api/ws` was 401'd by Traefik and silently retried forever (only the 5s REST poll kept the UI current). ## Fix - `/api/ws` gets its own higher-priority Traefik router **without** Basic auth. - The WS is still gated by `API_TOKEN` (nginx injects it on the handshake; backend also accepts `?token=`). - Deploy **fails closed** unless `CRYPTO_API_TOKEN` is set. - nginx `/api/ws` block split out so upgrade headers are only set there. - Reconnect backoff 2s → 30s. ## Testing - Backend: 79 tests pass (3 new WS auth cases: missing/header/query token), ruff clean. - Frontend: build + tests pass.
matitos added 1 commit 2026-09-19 14:52:59 +02:00
Serve /api/ws without Basic auth so the live feed connects
CI/CD / backend (pull_request) Successful in 5m58s
CI/CD / frontend (pull_request) Successful in 5m3s
CI/CD / build (pull_request) Skipped
CI/CD / deploy (pull_request) Skipped
CI/CD / cleanup (pull_request) Skipped
3e19612cc0
Browsers don't reliably replay Basic-auth credentials on a WebSocket upgrade,
so the dashboard's live feed was stuck on "reconnecting" (only the 5s REST
poll worked). Give /api/ws a higher-priority Traefik router that skips Basic
auth; the backend still requires API_TOKEN, which nginx injects on the
handshake. The deploy now fails closed unless CRYPTO_API_TOKEN is set.

Also: split the nginx /api/ws block so upgrade headers are only set there, and
add reconnect backoff (2s -> 30s) so a failing socket stops hammering.
matitos merged commit c9ee3e3aef into main 2026-09-19 15:11:18 +02:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: matitos/crypto_trading#3