mirror of
https://github.com/PerpetualSoftware/pad.git
synced 2026-09-23 19:06:33 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user