Self-healing Cloudflare Access recovery for the HA web frontend

Sharing a small utility I built after getting tired of manually re-authenticating my HA tabs behind Cloudflare Zero Trust every couple of weeks.

The pain: if you run HA behind Cloudflare Tunnel + Cloudflare Access (a very common setup, see the HOWTO guide), your browser tabs freeze when the CF_Authorization cookie expires. The UI shows “Unable to connect to Home Assistant.” Refreshing does nothing, HA’s Service Worker keeps serving the cached shell, and CORS hides the Cloudflare 302 redirect from background fetches. The only manual workaround is an awkward incognito-window trick.

The fix: ~80 lines of JS, one file in /config/www/, three lines in configuration.yaml.

Repo: GitHub - mayerwin/HA-Cloudflare-Access-Recovery: Self-healing Cloudflare Access auth for Home Assistant - recovers the HA web frontend in any browser (desktop or mobile) when the CF_Authorization cookie expires. · GitHub

README covers the root cause, install, and a verification test plan (force-expire the cookie in DevTools and watch the tab self-reload).

This is for the web frontend only. Companion app with mTLS is a separate story and unaffected. Works on Chrome, Edge, Firefox, Safari, Brave, Arc, mobile or desktop. MIT.

Filed it as a feature request against the cloudflared add-on repo too, but in the meantime, drop-in fix.