diff --git a/lib/plugin.js b/lib/plugin.js index 9ddee8c..e0523eb 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -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) diff --git a/test/fixture/pages/ssr.vue b/test/fixture/pages/ssr.vue index 6b8592b..a7a0a32 100644 --- a/test/fixture/pages/ssr.vue +++ b/test/fixture/pages/ssr.vue @@ -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++) } } }