Skip to content

Commit

Permalink
Pass xsrf token explicitly in the /pull POST request
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Jun 28, 2024
1 parent 1e3fb3c commit b0af4a9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,16 @@ export class GalleryWidget extends ReactWidget {
};
this._stream.connect(promiseResolver);
});
const xsrfTokenMatch = document.cookie.match('\\b_xsrf=([^;]*)\\b');
const args: Record<string, string | number> = {
exhibit_id: exhibit.id
};
if (xsrfTokenMatch) {
args['_xsrf'] = xsrfTokenMatch[1];
}
await requestAPI('pull', {
method: 'POST',
body: JSON.stringify({ exhibit_id: exhibit.id })
body: JSON.stringify(args)
});
await done;
}
Expand Down

0 comments on commit b0af4a9

Please sign in to comment.