Skip to content
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

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

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 17 additions & 12 deletions lib/plugin.template.js
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,18 +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: {
'Accept-Encoding': process.browser ? 'gzip, deflate, br' : 'gzip, deflate',
common : {
'Accept': 'application/json, text/plain, */*'
},
delete: {},
get: {},
head: {},
post: {},
put: {},
patch: {}
}
headers: headers
}

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