Improve schema_apply error handling and add credentials

- Add better JSON parsing with error logging
- Add credentials: same-origin to ensure session cookies are sent
- Show helpful error message when server returns invalid response

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Purple
2026-01-18 13:36:46 +00:00
parent 8a471edbe0
commit 38d1cf8c7a

View File

@@ -1321,9 +1321,18 @@ async function applySchemaUpdates() {
"Content-Type": "application/json",
"X-CSRF-Token": CSRF_TOKEN
},
credentials: "same-origin",
body: JSON.stringify({ csrf_token: CSRF_TOKEN })
});
const data = await response.json();
const text = await response.text();
let data;
try {
data = JSON.parse(text);
} catch (parseError) {
console.error("Failed to parse response:", text);
throw new Error("Server returned invalid response. Check error logs.");
}
if (!data.success) {
throw new Error(data.error || "Failed to apply schema changes");