Skip to content

Commit f7576e3

Browse files
farnabazpi0
authored andcommitted
feat: add support for custom token key in request header (#152)
1 parent b6cfad4 commit f7576e3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/schemes/local.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ export default class LocalScheme {
99
_setToken (token) {
1010
if (this.options.globalToken) {
1111
// Set Authorization token for all axios requests
12-
this.$auth.ctx.app.$axios.setToken(token)
12+
this.$auth.ctx.app.$axios.setHeader(this.options.tokenName, token)
1313
}
1414
}
1515

1616
_clearToken () {
1717
if (this.options.globalToken) {
1818
// Clear Authorization token for all axios requests
19-
this.$auth.ctx.app.$axios.setToken(false)
19+
this.$auth.ctx.app.$axios.setHeader(this.options.tokenName, false)
2020
}
2121
}
2222

@@ -99,5 +99,6 @@ export default class LocalScheme {
9999
const DEFAULTS = {
100100
tokenRequired: true,
101101
tokenType: 'Bearer',
102-
globalToken: true
102+
globalToken: true,
103+
tokenName: 'Authorization'
103104
}

0 commit comments

Comments
 (0)