fix(studio): saveProgress/loadProgress с JWT-заголовком (был 401 при сохранении прогресса)

loadProgress/saveProgress (лидерстаты/достижения) слали fetch без Authorization
→ 401 UNAUTHORIZED. Используют _economyAuthHeaders() (JWT игрока из localStorage).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
min 2026-06-06 10:01:38 +03:00
parent 33cd435d06
commit ce6e69a2e8

View File

@ -4442,7 +4442,8 @@ export class GameRuntime {
if (!url) return; if (!url) return;
try { try {
fetch(url, { fetch(url, {
method: 'POST', headers: { 'Content-Type': 'application/json' }, method: 'POST',
headers: this._economyAuthHeaders(), // JWT игрока (иначе 401)
body: JSON.stringify({ data }), body: JSON.stringify({ data }),
}).catch(() => {}); }).catch(() => {});
} catch (e) { /* ignore */ } } catch (e) { /* ignore */ }
@ -4451,7 +4452,8 @@ export class GameRuntime {
loadProgress(namespace, cb) { loadProgress(namespace, cb) {
const url = this._saveBaseUrl(namespace); const url = this._saveBaseUrl(namespace);
if (!url) { cb && cb(null); return; } if (!url) { cb && cb(null); return; }
fetch(url).then(r => r.json()) fetch(url, { headers: this._economyAuthHeaders() })
.then(r => r.json())
.then(j => cb && cb(j.data ?? null)) .then(j => cb && cb(j.data ?? null))
.catch(() => cb && cb(null)); .catch(() => cb && cb(null));
} }