diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-11-02 14:24:24 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-11-02 15:23:04 +0000 |
commit | 24817c65d4960e658c3d268d8590fe5e4344c80b (patch) | |
tree | 3f55a3decda0c82414ce46d03000f0b5a9b3d0ae /app | |
parent | 506a4e7530854ec4f4775b8df96a272509a553ba (diff) | |
download | gitlab-ce-24817c65d4960e658c3d268d8590fe5e4344c80b.tar.gz |
Add crsf token in axios calls39726-add-crsf-token-axios
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/clusters.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/axios_utils.js | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/app/assets/javascripts/clusters.js b/app/assets/javascripts/clusters.js index 661870c226c..c9fef94efea 100644 --- a/app/assets/javascripts/clusters.js +++ b/app/assets/javascripts/clusters.js @@ -1,6 +1,7 @@ /* globals Flash */ import Visibility from 'visibilityjs'; import axios from 'axios'; +import setAxiosCsrfToken from './lib/utils/axios_utils'; import Poll from './lib/utils/poll'; import { s__ } from './locale'; import initSettingsPanels from './settings_panels'; @@ -17,6 +18,7 @@ import Flash from './flash'; class ClusterService { constructor(options = {}) { this.options = options; + setAxiosCsrfToken(); } fetchData() { return axios.get(this.options.endpoint); diff --git a/app/assets/javascripts/lib/utils/axios_utils.js b/app/assets/javascripts/lib/utils/axios_utils.js new file mode 100644 index 00000000000..45bff245827 --- /dev/null +++ b/app/assets/javascripts/lib/utils/axios_utils.js @@ -0,0 +1,6 @@ +import axios from 'axios'; +import csrf from './csrf'; + +export default function setAxiosCsrfToken() { + axios.defaults.headers.common[csrf.headerKey] = csrf.token; +} |