fix(csrfToken): 更新CsrfToken的获取方式,改为从Cookie中获取

This commit is contained in:
OrangeM21
2020-08-19 17:25:34 +08:00
committed by 老广
parent 2832d876fd
commit 93dba0bbee

View File

@@ -1,6 +1,6 @@
import axios from 'axios'
import i18n from '@/i18n/i18n'
import { getTokenFromCookie } from '@/utils/auth'
import { Message, MessageBox } from 'element-ui'
import store from '@/store'
@@ -12,11 +12,12 @@ const service = axios.create({
})
function beforeRequestAddToken(config) {
if (store.getters.token) {
const csrfToken = getTokenFromCookie()
if (csrfToken) {
// let each request carry token
// ['X-Token'] is a custom headers key
// please modify it according to the actual situation
config.headers['X-CSRFToken'] = store.getters.token
config.headers['X-CSRFToken'] = csrfToken
}
if (store.getters.currentOrg) {
config.headers['X-JMS-ORG'] = store.getters.currentOrg.id