mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-11-08 00:54:33 +01:00
22 lines
700 B
JavaScript
22 lines
700 B
JavaScript
export default function ({ $axios, store }) {
|
|
$axios.onRequest(config => {
|
|
console.log('Making request to ' + config.url)
|
|
if (config.url.startsWith('http:') || config.url.startsWith('https:')) {
|
|
return
|
|
}
|
|
var bearerToken = store.state.user.user ? store.state.user.user.token : null
|
|
// console.log('Bearer token', bearerToken)
|
|
if (bearerToken) {
|
|
config.headers.common['Authorization'] = `Bearer ${bearerToken}`
|
|
}
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
config.url = `/dev${config.url}`
|
|
}
|
|
})
|
|
|
|
$axios.onError(error => {
|
|
const code = parseInt(error.response && error.response.status)
|
|
console.error('Axios error code', code)
|
|
})
|
|
} |