Skip to content

Commit f5dd2b9

Browse files
author
Diocrafts
committed
fix: add CSRF header to video thumbnail PUT requests
The double-submit CSRF middleware blocks all mutating requests without the X-CSRF-Token header. photos.js was uploading video thumbnails via PUT without it, causing a flood of 403 errors. - Add getCsrfHeaders() spread to the fetch headers - Add credentials: 'same-origin' to ensure cookie is sent
1 parent 661c9cb commit f5dd2b9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

static/js/features/library/photos.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,13 @@ const photosView = {
282282
// Upload to server for permanent caching
283283
const token = localStorage.getItem('token')
284284
|| sessionStorage.getItem('token');
285-
const headers = { 'Content-Type': blob.type };
285+
const headers = { 'Content-Type': blob.type, ...getCsrfHeaders() };
286286
if (token) headers['Authorization'] = `Bearer ${token}`;
287287

288288
fetch(`/api/files/${fileId}/thumbnail/preview`, {
289289
method: 'PUT',
290290
headers,
291+
credentials: 'same-origin',
291292
body: blob,
292293
}).then((resp) => {
293294
if (resp.ok) {

0 commit comments

Comments
 (0)