Skip to content

Commit

Permalink
Do not set CSRF Token when no csrf header (mastodon#10383)
Browse files Browse the repository at this point in the history
  • Loading branch information
hinaloe authored and hiyuki2578 committed Oct 2, 2019
1 parent 03fae51 commit ce280d1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/javascript/mastodon/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ export const getLinks = response => {
};

let csrfHeader = {};

function setCSRFHeader() {
const csrfToken = document.querySelector('meta[name=csrf-token]').content;
csrfHeader['X-CSRF-Token'] = csrfToken;
const csrfToken = document.querySelector('meta[name=csrf-token]');
if (csrfToken) {
csrfHeader['X-CSRF-Token'] = csrfToken.content;
}
}

ready(setCSRFHeader);

export default getState => axios.create({
Expand Down

0 comments on commit ce280d1

Please sign in to comment.