Skip to content

Commit 6c5605d

Browse files
author
pooya parsa
committed
fix(plugin): preserve default headers (fixes #323)
1 parent fd1f8ec commit 6c5605d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: lib/plugin.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,14 @@ export default (ctx, inject) => {
197197

198198
<% if (options.proxyHeaders) { %>
199199
// Proxy SSR request headers headers
200-
axiosOptions.headers.common = (ctx.req && ctx.req.headers) ? Object.assign({}, ctx.req.headers) : {}
201-
<% for (let h of options.proxyHeadersIgnore) { %>delete axiosOptions.headers.common['<%= h %>']
202-
<% } %><% } %>
200+
if (process.server && ctx.req && ctx.req.headers) {
201+
const reqHeaders = { ...ctx.req.headers }
202+
for (let h of <%= serialize(options.proxyHeadersIgnore) %>) {
203+
delete reqHeaders[h]
204+
}
205+
axiosOptions.headers.common = { ...reqHeaders, ...axiosOptions.headers.common }
206+
}
207+
<% } %>
203208

204209
if (process.server) {
205210
// Don't accept brotli encoding because Node can't parse it

0 commit comments

Comments
 (0)