added session_limit, adapted ajax calls (axios interceptor) in theme

This commit is contained in:
2021-09-16 21:40:18 +02:00
parent d26e21b5a5
commit a352b9745b
36 changed files with 197 additions and 54 deletions

View File

@ -5,7 +5,7 @@ import axios from 'axios'
// console.log('drupalSettings', drupalSettings)
console.log(window.location)
export const MGQ = axios.create({
const MGQ = axios.create({
baseURL: window.location.origin + '/mgq',
withCredentials: true,
headers: {
@ -15,3 +15,19 @@ export const MGQ = axios.create({
'Content-Type': 'application/json'
}
})
MGQ.interceptors.response.use(
response => {
return Promise.resolve(response)
},
error => {
const { status } = error.response
console.warn('error in graphql-axios', status)
if (status === 403) {
window.location = '/'
}
return Promise.reject(error)
}
)
export default MGQ

View File

@ -5,7 +5,7 @@ import axios from 'axios'
// console.log('drupalSettings', drupalSettings)
console.log(window.location)
export const JSONAPI = axios.create({
const JSONAPI = axios.create({
baseURL: window.location.origin+`/jsonapi`,
withCredentials: true,
headers: {
@ -14,3 +14,19 @@ export const JSONAPI = axios.create({
// 'Content-Type': 'application/json'
}
})
JSONAPI.interceptors.response.use(
response => {
return Promise.resolve(response)
},
error => {
const { status } = error.response
console.warn('error in json-axios', status)
if (status === 403) {
window.location = '/'
}
return Promise.reject(error)
}
)
export default JSONAPI

View File

@ -4,7 +4,7 @@ import axios from 'axios'
// console.log('drupalSettings', drupalSettings)
export const MA = axios.create({
const MA = axios.create({
baseURL: window.location.origin + '/' + drupalSettings.path.pathPrefix,
withCredentials: true,
headers: {
@ -12,3 +12,21 @@ export const MA = axios.create({
// "X-CSRF-Token": "csrf_token"
}
})
MA.interceptors.response.use(
response => {
// console.log('ma-axios interceptor response', response)
return Promise.resolve(response)
// return response
},
error => {
const { status } = error.response
console.warn('error in ma-axios interceptor', status)
if (status === 403) {
window.location = '/'
}
return Promise.reject(error)
}
)
export default MA

View File

@ -5,7 +5,7 @@ import axios from 'axios'
// console.log('drupalSettings', drupalSettings)
// console.log('window.location.origin', window.location.origin)
export const REST = axios.create({
const REST = axios.create({
baseURL: window.location.origin + '/' + drupalSettings.path.pathPrefix,
withCredentials: true,
headers: {
@ -13,3 +13,19 @@ export const REST = axios.create({
'Content-Type': 'application/json'
}
})
REST.interceptors.response.use(
response => {
return Promise.resolve(response)
},
error => {
const { status } = error.response
console.warn('error in rest-axios', status)
if (status === 403) {
window.location = '/'
}
return Promise.reject(error)
}
)
export default REST