mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-20 02:31:43 +00:00
fix(csrfToken): 更新CsrfToken的获取方式,改为从Cookie中获取
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user