Skip to content
Permalink
Browse files

fix: don't toLowerCase headers for `setHeader` and `setToken` (#250)

  • Loading branch information...
pi0 committed May 23, 2019
1 parent 062027f commit 93469f026ee0ad4d1e3946a793db611153198df0
Showing with 3 additions and 5 deletions.
  1. +1 −3 lib/plugin.js
  2. +2 −2 test/fixture/pages/ssr.vue
@@ -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];
@@ -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)
@@ -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() {
@@ -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++)
}
}
}

0 comments on commit 93469f0

Please sign in to comment.
You can’t perform that action at this time.