diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2019-03-11 22:33:21 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2019-03-11 22:33:21 +0300 |
commit | a0b3f621dce168ab31a3a4ccf37dbd3d97368ebd (patch) | |
tree | 8e0a108015cf3dfa7737682c3ce57e371141a1ff | |
parent | 496f9a9ea905a69a17baf72cd0094917068f8722 (diff) |
Removes the CSRF token if the emojis.json is on a CDN
-rw-r--r-- | app/assets/javascripts/emoji/index.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/assets/javascripts/emoji/index.js b/app/assets/javascripts/emoji/index.js index 36542315c4c..bb5085a1911 100644 --- a/app/assets/javascripts/emoji/index.js +++ b/app/assets/javascripts/emoji/index.js @@ -3,6 +3,7 @@ import createFlash from '~/flash'; import { s__ } from '~/locale'; import emojiAliases from 'emojis/aliases.json'; import axios from '../lib/utils/axios_utils'; +import csrf from '../lib/utils/csrf'; import AccessorUtilities from '../lib/utils/accessor'; @@ -24,7 +25,14 @@ export function initEmojiMap() { resolve(emojiMap); } else { // We load the JSON from server - axios + const axiosInstance = axios.create(); + + // If the static JSON file is on a CDN we don't want to send the default CSRF token + if (gon.asset_host) { + delete axiosInstance.defaults.headers.common[csrf.headerKey]; + } + + axiosInstance .get( `${gon.asset_host || ''}${gon.relative_url_root || ''}/-/emojis/${EMOJI_VERSION}/emojis.json`, |