User context (user_id) is always None from Companion App, even with correct proxy/network config

Hello, I have a persistent issue where both trigger.user_id (from tag scans) and context.user_id (from UI button presses) are None when the event comes from the mobile app via my internal/external URL. My setup is Home Assistant Core running in Docker on an Orange Pi, accessed via a Cloudflare Tunnel.

Here is everything I have already tried and verified:

  1. Person/User Links: All users are correctly linked to their respective person entities.
  2. trusted_proxies: My http configuration in configuration.yaml is correctly set up with use_x_forwarded_for: true and trusted_proxies including my Docker network (172.17.0.0/16) and the official Cloudflare IP ranges.
  3. Restarts: Home Assistant has been fully restarted after every configuration change.
  4. Custom Integrations: I found an error in my logs (Integration 'remote_homeassistant' not found) and tried to solve it by:
  • Disabling browser_mod.
  • Creating a dummy remote_homeassistant component to satisfy the dependency.
  • Neither of these steps solved the user_id issue.
  1. The Final Test: Bypassing Cloudflare: I completely bypassed my Cloudflare Tunnel by setting up a direct port forward on my router to my Home Assistant instance. The issue still persists. Even with a direct connection from the mobile app to my public IP, the context.user_id arrives as None.

The Companion App clearly shows it is logged in with the correct user, but this context is lost somewhere before the automation trigger. At this point, I suspect a very specific bug or a corruption issue within my HA Core instance.

Any ideas on what could be happening at a deeper level?

iOS or Android?

Both OS! Do you have any idea what it could be?