Commit a631b91b authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Fix mixed-content-blocked API calls in the production build + harden auth-failure recovery

Two compounding bugs behind "cannot sign in" / protected pages showing a
blank page instead of prompting to log in:

1. The production build (vite build, mode=production) doesn't read
   .env.development.local - only .env - so it baked in the raw
   http://144.76.210.145:8000 absolute URL instead of the /api proxy path.
   Since the page is served over https:// (via vite preview, see
   stax_dev_mode_is_the_real_slowness in project memory), the browser
   silently blocked every single fetch as mixed content - no server-side
   error, just every API call failing client-side. Added
   .env.production.local (gitignored, documented in .env.example so a
   fresh checkout doesn't regress) with the same /api override
   .env.development.local already used for dev mode.

2. AuthContext's role-fetch effect only recognized a clean 401 ApiError as
   "not authenticated" - a mixed-content-blocked fetch throws a raw
   TypeError instead, which the old check didn't recognize, so `role`
   stayed null forever and RequireRole rendered a blank page indefinitely
   instead of ever redirecting to /login. Now only a 5xx (a transient
   server hiccup) is treated as "stay logged in, don't overreact" -
   everything else, including a network-level failure, is treated as "not
   authenticated" so the user always gets a login prompt instead of
   silence.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent 9d69f811
Pipeline #1088 failed with stage