Re-authentication issue on first browser session (haproxy)

I have HASS configured behind HAproxy. HAproxy does SSL offloading for my HA instance. When I start a fresh instance of Firefox on my desktop, on the first connection to HASS, the login page appears, then after 10-12 seconds it automatically refreshes. If I login during this 10-12 second window, I can interact with HASS, but then it kicks me out, back to the login page.

The strange thing is I cannot reproduce this if I connect to the non-HAproxy site (i.e. :8123). I have the browser’s web developer traces but I am unsure where to look. Any help would be appreciated.

Thanks!

Edit: I forgot to mention, this is not an issue on subsequent logins with the same browser.

Did a packet capture and found the client going though HAproxy loads different content, the largest of which is the service_worker.js. I noticed that once all the .js files load (there is lots of them), the page refreshes (and will kick you out of a logged in session).

I believe I found a fix. In HAProxy, I have a single frontend servicing multiple backends. Moving my Home Assistant frontend configuration to the top of the list seems to resolve this problem.