Merge pull request #356 from christianlouis/copilot/fix-file-upload-regression

fix(ui): send X-CSRF-Token on file upload XHR and retry fetch calls
This commit is contained in:
Christian Krakau-Louis
2026-02-22 22:44:23 +01:00
committed by GitHub
2 changed files with 10 additions and 2 deletions
+6
View File
@@ -140,6 +140,12 @@ async function uploadFile(file, progressBar, statusEl, statusMessage) {
const xhr = new XMLHttpRequest();
xhr.open("POST", "/api/ui-upload", true);
// Attach CSRF token so the server-side CSRF middleware accepts the request.
const csrfToken = typeof getCsrfToken === 'function' ? getCsrfToken() : '';
if (csrfToken) {
xhr.setRequestHeader("X-CSRF-Token", csrfToken);
}
xhr.upload.onprogress = (e) => {
if (e.lengthComputable) {
const percentComplete = (e.loaded / e.total) * 100;
+4 -2
View File
@@ -599,7 +599,8 @@
const response = await fetch(`/api/files/${fileId}/reprocess`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
'X-CSRF-Token': getCsrfToken()
}
});
@@ -651,7 +652,8 @@
const response = await fetch(`/api/files/${fileId}/retry-subtask?subtask_name=${subtaskName}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
'X-CSRF-Token': getCsrfToken()
}
});