Skip to content

fix(defaults): set proper Accept-Encoding for server side #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 7, 2018
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions lib/plugin.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,22 @@ const setupProgress = (axios, ctx) => {
}<% } %>

export default (ctx, inject) => {
let headers = {
common : {
'Accept': 'application/json, text/plain, */*'
},
delete: {},
get: {},
head: {},
post: {},
put: {},
patch: {}
}

if (process.server) {
headers['Accept-Encoding'] = 'gzip, deflate'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be in common I think 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manniL @pi0 don't know why but It didn't work for me when it's in common.

tried it locally.

}

const axiosOptions = {
// baseURL
baseURL : process.browser
Expand All @@ -157,17 +173,7 @@ export default (ctx, inject) => {
// Create fresh objects for all default header scopes
// Axios creates only one which is shared across SSR requests!
// https://github.com/mzabriskie/axios/blob/master/lib/defaults.js
headers: {
common : {
'Accept': 'application/json, text/plain, */*'
},
delete: {},
get: {},
head: {},
post: {},
put: {},
patch: {}
}
headers: headers
}

<% if (options.proxyHeaders) { %>
Expand Down