Skip to content

Commit 2e514a4

Browse files
author
pooya parsa
committed
feat: convert header names to lowercase (nuxt/http#45)
1 parent 90e8c13 commit 2e514a4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/plugin.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import Axios from 'axios'
44
// Axios.prototype cannot be modified
55
const axiosExtra = {
66
setHeader (name, value, scopes = 'common') {
7+
name = name.toLowerCase()
8+
79
for (let scope of Array.isArray(scopes) ? scopes : [ scopes ]) {
810
if (!value) {
911
delete this.defaults.headers[scope][name];
@@ -14,7 +16,7 @@ const axiosExtra = {
1416
},
1517
setToken (token, type, scopes = 'common') {
1618
const value = !token ? null : (type ? type + ' ' : '') + token
17-
this.setHeader('Authorization', value, scopes)
19+
this.setHeader('authorization', value, scopes)
1820
},
1921
onRequest(fn) {
2022
this.interceptors.request.use(config => fn(config) || config)

test/fixture/pages/ssr.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let reqCtr = 1
1212
export default {
1313
computed: {
1414
axiosSessionId() {
15-
return this.$axios.defaults.headers.common.sessionId
15+
return this.$axios.defaults.headers.common.sessionid
1616
},
1717
1818
axiosEncoding() {

0 commit comments

Comments
 (0)