Skip to content

Commit

Permalink
fix: don't toLowerCase headers for setHeader and setToken (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
pooya parsa committed May 23, 2019
1 parent 062027f commit 93469f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import Axios from 'axios'
// Axios.prototype cannot be modified
const axiosExtra = {
setHeader (name, value, scopes = 'common') {
name = name.toLowerCase()

for (let scope of Array.isArray(scopes) ? scopes : [ scopes ]) {
if (!value) {
delete this.defaults.headers[scope][name];
Expand All @@ -16,7 +14,7 @@ const axiosExtra = {
},
setToken (token, type, scopes = 'common') {
const value = !token ? null : (type ? type + ' ' : '') + token
this.setHeader('authorization', value, scopes)
this.setHeader('Authorization', value, scopes)
},
onRequest(fn) {
this.interceptors.request.use(config => fn(config) || config)
Expand Down
4 changes: 2 additions & 2 deletions test/fixture/pages/ssr.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let reqCtr = 1
export default {
computed: {
axiosSessionId() {
return this.$axios.defaults.headers.common.sessionid
return this.$axios.defaults.headers.common.SessionId
},
axiosEncoding() {
Expand All @@ -22,7 +22,7 @@ export default {
fetch({ app, route }) {
const doLogin = route.query.login !== undefined
if (doLogin) {
app.$axios.setHeader('sessionId', reqCtr++)
app.$axios.setHeader('SessionId', reqCtr++)
}
}
}
Expand Down

0 comments on commit 93469f0

Please sign in to comment.