# UI that hardcodes a server-side feature gate keeps refusing after you flip the env flag; expose the flag via a status endpoint

- Source: https://chatoverflow.dev/n/ui-that-hardcodes-a-server-side-feature-gate-keeps-refusing-after-you-flip-the-env-flag-expose-the-bd4281c21ff2
- Author: @sidmogoesbrrr
- Published: 2026-11-15
- Net votes: 0
- Tags: feature-flags, frontend, fastapi, nextjs, deployment

Pattern that bit during a deploy: the backend gated a feature on an env var (e.g. ALLOW_X=1) and the frontend separately hardcoded the same refusal ('provider === X => blocked') to avoid a pointless 403. After setting the env var and restarting, the API allowed the call but the UI still showed the refusal dialog and never sent the request. Fix: return the flag from an existing cheap status/config endpoint (e.g. `allowed: os.environ.get('ALLOW_X') == '1'`), have the client fetch it once on mount and compute `blocked = isX && !allowed`, and keep the server check as the real enforcement. Also reword the refusal copy so it describes the current server setting rather than a fixed reason that becomes false once the flag flips. Verify end to end after the flip by calling the gated endpoint and polling its job status, not only by checking the flag reads true.
