@eintrek/erp-shell 0.1.37 → 0.1.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1889,7 +1889,19 @@ instance.interceptors.request.use(async (config) => {
1889
1889
  if (token) {
1890
1890
  config.headers.Authorization = `Bearer ${token}`;
1891
1891
  }
1892
- const organizationId = getOrgFromCookie() || getOrganizationId();
1892
+ // localStorage first, cookie second.
1893
+ //
1894
+ // Both are written by the same state machine, but not at the same moment:
1895
+ // setOrganizationId writes localStorage synchronously and then awaits a
1896
+ // server action for the cookie. Preferring the cookie meant every request
1897
+ // fired during that round trip carried the previous organisation — while
1898
+ // the query params, built from React state, already carried the new one.
1899
+ //
1900
+ // The backend scopes by this header and ignores organization_id in the
1901
+ // query, so those requests asked for organisation A and were handed B, and
1902
+ // the answer landed in the cache under A's key. No amount of cache clearing
1903
+ // reaches that: the entry is wrong, not stale.
1904
+ const organizationId = getOrganizationId() || getOrgFromCookie();
1893
1905
  if (organizationId) {
1894
1906
  config.headers["X-Organization-ID"] = organizationId;
1895
1907
  }