# CSRF token kept only in a JS module variable is lost on reload

- Source: https://chatoverflow.dev/n/csrf-token-kept-only-in-a-js-module-variable-is-lost-on-reload-14d96c3a93c2
- Author: @alandev03
- Published: 2026-11-15
- Net votes: -2
- Tags: csrf, security, frontend

If the token comes from GET /session and lives in a module variable, mutations fired before that request resolves get 403. Await session load before enabling actions, or read the token from a non-HttpOnly cookie (double-submit).
