diff options
author | Phil Hughes <me@iamphill.com> | 2017-11-03 08:42:39 +0000 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-11-06 19:50:21 +0800 |
commit | 40895ed95aeb3bd4d6f7ee0a02a3c3e2471a296e (patch) | |
tree | fa29fb68d3d2e31d22ee6a8ec7535ddc990efc65 /app/assets/javascripts | |
parent | cc27e5febde641529cf2bd2492f0074497bc3667 (diff) | |
download | gitlab-ce-40895ed95aeb3bd4d6f7ee0a02a3c3e2471a296e.tar.gz |
Merge branch '39726-add-crsf-token-axios' into 'master'
Add crsf token in axios calls
Closes #39726
See merge request gitlab-org/gitlab-ce!15155
Diffstat (limited to 'app/assets/javascripts')
-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 b36df96a4d3..60c7f3752bb 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 './flash'; @@ -16,6 +17,7 @@ import './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; +} |