The app returned 401 on every request because jwtVerify could not fetch
the Cloudflare Access signing keys (getaddrinfo EAI_AGAIN): kai-sa-cam
was only attached to internal networks (kai-sa-cam-internal and the
external kai-sa-cam-tunnel, which has Internal=true), so it had no DNS
or route to the Internet.
Network
- add a dedicated kai-sa-cam-egress bridge network, attached to
kai-sa-cam only
- kai-sa-go2rtc stays on kai-sa-cam-internal only (no published ports,
no outbound access); the video stream remains reachable solely through
the authenticated /go2rtc proxy
Auth (index.ts)
- log the reason when an Access JWT is rejected instead of silently
returning 401
- fail closed: exit at startup when CF_ACCESS_TEAM_DOMAIN or
CF_ACCESS_AUD is missing, unless ALLOW_NO_AUTH=1
Media (media.ts)
- replace inline require() calls with ESM imports (resolve, mkdirSync)
- resolve the path first, then check it against MEDIA_DIR + path.sep
(previous check ran after existsSync and accepted sibling prefixes)
- on export, delete files only on the response "finish" event, not when
the archive is finalized, so an interrupted download no longer loses
media
- snapshots: stop calling reject() after the response was sent, which
caused unhandled rejections
Recorder (recorder.ts)
- enforce DISK_MIN_FREE_GB with statfsSync (was a stub returning true)
- track the recording in a single state object and wait on an exit
promise instead of polling; make cleanup idempotent
- return 502 when ffmpeg exits right after start
- recover orphaned .part files at startup
- return file names instead of full paths from /start, /stop and /status
- add apiFetch wrapper with re-auth popup, retry and session monitor
- proxy go2rtc through the app (/go2rtc) and drop the public stream hostname
- route WebSocket upgrades manually (the talk WSS was rejecting go2rtc MSE)
- harden talkback: paplay error handling, heartbeat, single speaker, reconnect
- sync recording state with the server on load and on 409
- optionally verify Cf-Access-Jwt-Assertion (CF_ACCESS_TEAM_DOMAIN/AUD)
- keep go2rtc on the internal network only
- remove unused env vars, update README and cam-watch script