fix: check HTTP status in admin settings save (PR #91)

savePlatformSettings used raw fetch which doesn't throw on 4xx/5xx,
so failed saves (CSRF rejection, auth errors) silently showed "Saved".
Now checks resp.ok before reporting success.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
xarmian
2026-04-13 01:41:41 +00:00
parent b027046605
commit da2997c564
+2 -1
View File
@@ -161,12 +161,13 @@
const headers: Record<string, string> = { 'Content-Type': 'application/json' };
const csrf = getCSRFToken();
if (csrf) headers['X-CSRF-Token'] = csrf;
await fetch(BASE + '/admin/settings', {
const resp = await fetch(BASE + '/admin/settings', {
method: 'PATCH',
credentials: 'same-origin',
headers,
body: JSON.stringify(platformSettings)
});
if (!resp.ok) throw new Error(`${resp.status}`);
platformStatus = 'saved';
setTimeout(() => (platformStatus = 'idle'), 2000);
} catch {