From 872eab57847e21a349e02af3260a6d6b3f550ecb Mon Sep 17 00:00:00 2001 From: Hinaloe Date: Tue, 26 Mar 2019 19:13:20 +0900 Subject: [PATCH] [Glitch] Do not set CSRF Token when no csrf header Port 68f2211f00dfa3f823ad780ed748c1af0078a0cf to glitch-soc --- app/javascript/flavours/glitch/util/api.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/javascript/flavours/glitch/util/api.js b/app/javascript/flavours/glitch/util/api.js index 033d2d67b..c59a24518 100644 --- a/app/javascript/flavours/glitch/util/api.js +++ b/app/javascript/flavours/glitch/util/api.js @@ -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({