diff --git a/lib/plugin.js b/lib/plugin.js index e193d78..56a576c 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -2,6 +2,9 @@ import KY from 'ky-universal' class HTTP { constructor(defaults, ky = KY) { + const headers = defaults.headers + delete defaults.headers + this._defaults = { hooks: {}, headers: {}, @@ -9,9 +12,15 @@ class HTTP { ...defaults } this._ky = ky + + for (const name in headers) { + this.setHeader(name, headers[name]) + } } setHeader(name, value) { + name = name.toLowerCase() + if (!value) { delete this._defaults.headers[name]; } else { diff --git a/test/fixture/pages/ssr.vue b/test/fixture/pages/ssr.vue index 217ac36..d8771b1 100644 --- a/test/fixture/pages/ssr.vue +++ b/test/fixture/pages/ssr.vue @@ -12,7 +12,7 @@ let reqCtr = 1 export default { computed: { httpSessionId() { - return this.$http._defaults.headers.sessionId + return this.$http._defaults.headers.sessionid }, httpEncoding() {