Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: send CSRF-Token with GET requests #54605

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion client/src/utils/ajax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export interface ResponseWithData<T> {
// TODO: Might want to handle flash messages as close to the request as possible
// to make use of the Response object (message, status, etc)
async function get<T>(path: string): Promise<ResponseWithData<T>> {
const response = await fetch(`${base}${path}`, defaultOptions);
const response = await fetch(`${base}${path}`, {
...defaultOptions,
headers: { 'CSRF-Token': getCSRFToken() }
});

return combineDataWithResponse(response);
}
Expand Down