Skip to content
Permalink
Browse files
feat(plugin): enable server brotli if supported (closes #276)
  • Loading branch information
pooya parsa committed Apr 21, 2020
1 parent 18afe5c commit 074f98cbdf409473357b2cd24cd6cb13fe75f149
Showing 1 changed file with 9 additions and 2 deletions.
@@ -4,6 +4,13 @@ import defu from 'defu'

const globalName = '<%= globalName %>'

// Check Node.js brotli support
let brotliSupported
if (process.server) {
const zlib = require('zlib')
brotliSupported = typeof zlib.createBrotliDecompress == 'function'
}

// Axios.prototype cannot be modified
const axiosExtra = {
setBaseURL (baseURL) {
@@ -206,8 +213,8 @@ export default (ctx, inject) => {
}
<% } %>

if (process.server) {
// Don't accept brotli encoding because Node can't parse it
// Don't accept brotli encoding because Node can't parse it
if (process.server && !brotliSupported) {
axiosOptions.headers.common['accept-encoding'] = 'gzip, deflate'
}

0 comments on commit 074f98c

Please sign in to comment.