mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-07 21:44:51 +00:00
* fix(csrf-token): add leading dot to session domain cookie. * refactor: remove generate key, upgrade axios and keep session domain in null. * refactor: fix PSR-12 code styles for PHP 8.2 compatibility. --------- Co-authored-by: Darko Gjorgjijoski <5760249+gdarko@users.noreply.github.com>
32 lines
590 B
JavaScript
Vendored
32 lines
590 B
JavaScript
Vendored
import axios from 'axios'
|
|
import Ls from '@/scripts/services/ls.js'
|
|
|
|
window.Ls = Ls
|
|
window.axios = axios
|
|
axios.defaults.withCredentials = true
|
|
|
|
axios.defaults.headers.common = {
|
|
'X-Requested-With': 'XMLHttpRequest',
|
|
}
|
|
|
|
/**
|
|
* Interceptors
|
|
*/
|
|
|
|
axios.interceptors.request.use(function (config) {
|
|
// Pass selected company to header on all requests
|
|
const companyId = Ls.get('selectedCompany')
|
|
|
|
const authToken = Ls.get('auth.token')
|
|
|
|
if (authToken) {
|
|
config.headers.Authorization = authToken
|
|
}
|
|
|
|
if (companyId) {
|
|
config.headers.company = companyId
|
|
}
|
|
|
|
return config
|
|
})
|